:root {
  --bg: #0a0b0f;
  --text: #ffffff;
  --muted: #a7adba;
  --accent: #3b78ff;
  --accent-2: #6f5cff;
  --badge: #3b78ff;
  --radius: 20px;

  /* Жидкое стекло */
  --glass: rgba(255, 255, 255, 0.07);
  --glass-2: rgba(255, 255, 255, 0.11);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --gloss: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  --blur: 22px;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  /* Цветная подложка, сквозь которую «просвечивает» стекло */
  background:
    radial-gradient(900px 520px at 10% -10%, rgba(59,120,255,0.34), transparent 60%),
    radial-gradient(760px 520px at 105% 0%, rgba(111,92,255,0.26), transparent 55%),
    radial-gradient(820px 640px at 50% 120%, rgba(59,120,255,0.18), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

#app { max-width: 720px; margin: 0 auto; padding: 16px 14px 0; }

.screen { display: block; }
.view { display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Базовое «стекло» */
.glass, .search, .recent-item, .vcard, .ch-card, .tc-row, .lb-row,
.back-btn, .fav-btn, .status-card, .menu-row, .gate-icon, .empty-icon,
.vote-btn, .rubric {
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), var(--gloss);
}

/* --- Поиск --- */
.search {
  display: flex; align-items: center; gap: 10px;
  border-radius: 999px; padding: 14px 18px; margin-bottom: 16px;
}
.search i { color: var(--muted); font-size: 20px; }
.search input {
  flex: 1; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 16px;
}
.search input::placeholder { color: var(--muted); }

/* --- Баннеры --- */
.banner-row {
  display: flex; gap: 12px; overflow-x: auto; margin-bottom: 18px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.banner-row::-webkit-scrollbar { display: none; }
.banner {
  flex: 0 0 88%;
  background: linear-gradient(120deg, rgba(111,92,255,0.85), rgba(59,120,255,0.85));
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow), var(--gloss);
  border-radius: var(--radius);
  padding: 22px 20px; min-height: 132px;
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
.banner h3 { margin: 0; font-size: 22px; font-weight: 800; text-transform: uppercase; line-height: 1.1; }
.banner span { color: rgba(255,255,255,0.9); font-size: 14px; }

/* --- Сетка рубрик --- */
.rubrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.rubric {
  position: relative; aspect-ratio: 1 / 0.84; border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  background:
    radial-gradient(120% 90% at 70% 110%, rgba(59,120,255,0.45), transparent 60%),
    var(--glass);
}
.rubric .glyph {
  position: absolute; right: 8px; top: 30px; bottom: 40px; left: 8px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.42); font-size: 90px;
}
.rubric .glyph.emoji { font-size: 60px; color: inherit; }
.rubric .count {
  position: absolute; top: 12px; right: 12px;
  background: rgba(59,120,255,0.85); color: #fff; box-shadow: var(--gloss);
  min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.rubric .name {
  position: absolute; left: 14px; bottom: 12px; right: 14px;
  font-size: 19px; font-weight: 800; text-transform: uppercase; line-height: 1.05;
}

/* --- Заголовки секций / списки --- */
.section-title { font-size: 14px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 4px 0 12px; letter-spacing: 0.04em; }
.recent { display: flex; flex-direction: column; gap: 10px; }
.recent-item { display: flex; gap: 12px; align-items: center; border-radius: 16px; padding: 12px; }
.recent-thumb {
  width: 52px; height: 52px; flex: 0 0 52px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px;
}
.recent-meta b { display: block; font-size: 15px; font-weight: 600; }
.recent-meta span { color: var(--muted); font-size: 13px; }

/* --- Карточка материала --- */
.item-cover {
  width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  background-size: cover; background-position: center;
  margin-bottom: 16px; border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow);
}
.item-cover.empty { display: flex; align-items: center; justify-content: center; font-size: 52px; color: rgba(255,255,255,0.5); }
.item-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.item-head h1 { font-size: 22px; font-weight: 800; margin: 0; flex: 1; line-height: 1.2; }
.fav-btn {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%;
  color: var(--muted); font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.fav-btn.active { color: #ffcb45; }
.fav-btn.active i { font-weight: 700; }
.item-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tag-pill { font-size: 12px; color: #a9c2ff; background: rgba(59,120,255,0.18); border: 1px solid rgba(59,120,255,0.25); padding: 4px 12px; border-radius: 999px; }
.item-desc { font-size: 15px; line-height: 1.6; color: #dfe2ea; white-space: pre-wrap; margin: 0 0 18px; }
.tc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.tc-row { display: flex; gap: 12px; align-items: center; border-radius: 14px; padding: 12px 14px; }
.tc-time { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 700; color: #a9c2ff; background: rgba(59,120,255,0.18); padding: 2px 10px; border-radius: 8px; font-size: 13px; }
.tc-title { font-size: 14px; }
.item-actions { position: sticky; bottom: calc(80px + env(safe-area-inset-bottom)); }
.watch-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; font-size: 16px; }

/* --- Кнопка «Назад» --- */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px; color: var(--text);
  padding: 10px 14px; border-radius: 14px; font-size: 15px; cursor: pointer; margin-bottom: 14px;
}
.back-btn i { font-size: 18px; }

/* --- Челленджи --- */
.ch-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.ch-card { border-radius: 16px; padding: 14px; background: var(--glass); backdrop-filter: blur(var(--blur)) saturate(150%); -webkit-backdrop-filter: blur(var(--blur)) saturate(150%); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow), var(--gloss); }
.ch-card.is-done { opacity: 0.6; }
.ch-top { display: flex; align-items: center; gap: 10px; }
.ch-top b { flex: 1; font-size: 15px; font-weight: 700; }
.ch-pts { font-weight: 800; color: #ffcb45; }
.ch-desc { margin: 8px 0 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.ch-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.ch-dl { font-size: 12px; color: var(--muted); }
.ch-done-btn { margin-left: auto; border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font: inherit; font-weight: 600; font-size: 13px; padding: 9px 16px; border-radius: 12px; cursor: pointer; box-shadow: 0 6px 16px rgba(59,120,255,0.4), var(--gloss); }
.ch-done { margin-left: auto; font-size: 13px; font-weight: 700; color: #36d399; }

/* --- Большие карточки материалов --- */
.vcard { border-radius: var(--radius); overflow: hidden; cursor: pointer; }
.vcard-cover {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  background-size: cover; background-position: center;
}
.vcard-cover.empty { display: flex; align-items: center; justify-content: center; font-size: 46px; color: rgba(255,255,255,0.55); }
.vcard-fav {
  position: absolute; top: 10px; right: 10px;
  width: 38px; height: 38px; font-size: 19px; border-radius: 50%;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.vcard-fav.active { color: #ffcb45; }
.vcard-body { padding: 12px 14px 14px; }
.vcard-title { display: block; font-size: 16px; font-weight: 700; line-height: 1.25; margin-bottom: 6px; }
.vcard-type { display: inline-block; font-size: 12px; color: #a9c2ff; background: rgba(59,120,255,0.18); border: 1px solid rgba(59,120,255,0.25); padding: 3px 10px; border-radius: 999px; }
.vcard-desc {
  margin: 8px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.bottom-spacer { height: 92px; }

/* --- Нижняя навигация (стекло) --- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  background: rgba(18,20,28,0.55);
  backdrop-filter: blur(26px) saturate(160%); -webkit-backdrop-filter: blur(26px) saturate(160%);
  border-top: 1px solid var(--glass-border);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.35), var(--gloss);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.tab {
  flex: 1; background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; padding: 6px 0; cursor: pointer;
}
.tab i { font-size: 22px; }
.tab.active { color: #fff; }
.tab.active i { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-radius: 12px; padding: 6px 14px; box-shadow: 0 4px 14px rgba(59,120,255,0.5); }

/* --- Гейт / ошибка / загрузка --- */
.gate { text-align: center; padding: 64px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gate-icon { width: 64px; height: 64px; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 30px; color: #fff; }
.gate h1 { font-size: 22px; margin: 0; }
.btn {
  display: inline-block; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; text-decoration: none; padding: 14px 22px; border-radius: 14px; font-weight: 700;
  margin-top: 8px; border: 0; cursor: pointer;
  box-shadow: 0 8px 22px rgba(59,120,255,0.45), var(--gloss);
}

/* --- Пустые состояния --- */
.empty { text-align: center; padding: 72px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-icon { width: 60px; height: 60px; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 28px; color: #fff; }
.empty h2 { margin: 0; font-size: 20px; }

/* --- Профиль --- */
.profile-head { display: flex; align-items: center; gap: 14px; padding: 8px 2px 18px; }
.avatar {
  width: 60px; height: 60px; flex: 0 0 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff; box-shadow: 0 6px 18px rgba(59,120,255,0.4), var(--gloss);
}
.profile-id b { display: block; font-size: 19px; font-weight: 700; }
.profile-id span.muted { font-size: 14px; }
.rank-badge { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700;
  background: rgba(59,120,255,0.2); color: #a9c2ff; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; }

.status-card { display: flex; align-items: center; gap: 12px; border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; }
.status-card i { font-size: 26px; color: #36d399; }
.status-card.inactive i { color: var(--muted); }
.status-card b { display: block; font-size: 15px; }
.status-card span { font-size: 13px; }

/* очки + рейтинг */
.points-card {
  display: flex; align-items: baseline; gap: 10px;
  background: linear-gradient(120deg, rgba(111,92,255,0.9), rgba(59,120,255,0.9));
  border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow), var(--gloss);
  border-radius: 16px; padding: 16px 18px; margin-bottom: 18px;
}
.points-num { font-size: 30px; font-weight: 800; }
.points-meta { font-size: 14px; color: rgba(255,255,255,0.9); }
.lb { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.lb-row { display: flex; align-items: center; gap: 12px; border-radius: 14px; padding: 12px 14px; }
.lb-row.me { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--glass-shadow); }
.lb-pos { flex: 0 0 24px; text-align: center; font-weight: 800; color: var(--muted); }
.lb-name { flex: 1; font-size: 14px; font-weight: 600; }
.lb-rank { font-size: 11px; color: #a9c2ff; background: rgba(59,120,255,0.18); padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.lb-pts { font-weight: 800; color: #a9c2ff; }
.vote-btn { flex: 0 0 auto; color: var(--text); font: inherit; font-size: 12px; font-weight: 600; padding: 7px 12px; border-radius: 10px; cursor: pointer; }
.vote-btn.voted { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(59,120,255,0.45), var(--gloss); }

/* --- Команда (минимализм) --- */
.sq-head { border-radius: 16px; padding: 16px 18px; margin-bottom: 12px;
  background: var(--glass); backdrop-filter: blur(var(--blur)) saturate(150%); -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow), var(--gloss); }
.sq-name { font-size: 19px; font-weight: 800; }
.sq-goal { margin-top: 6px; font-size: 13px; color: var(--muted); }
.sq-chat { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  color: #a9c2ff; font-weight: 600; font-size: 14px; padding: 12px; border-radius: 14px; margin-bottom: 14px;
  background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); }
.sq-line { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.sq-line i { color: #a9c2ff; font-size: 18px; }
.sq-line b { color: var(--text); }

.sq-edit { display: flex; gap: 8px; margin: 0 0 14px; }
.sq-edit input, .sq-edit select { flex: 1; min-width: 0; padding: 11px 13px; border-radius: 12px;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,0.05); color: var(--text); font: inherit; font-size: 14px; outline: 0; }
.sq-edit input:focus, .sq-edit select:focus { border-color: var(--accent); }
.sq-btn { flex: 0 0 auto; border: 0; border-radius: 12px; padding: 0 16px; font: inherit; font-size: 13px; font-weight: 600;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); cursor: pointer; box-shadow: var(--gloss); }

.sq-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.sq-member { border-radius: 14px; padding: 12px 14px;
  background: var(--glass); backdrop-filter: blur(var(--blur)) saturate(150%); -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); }
.sq-row { display: flex; align-items: center; gap: 10px; }
.sq-row .lb-name { flex: 1; font-size: 14px; font-weight: 600; }
.sq-votes { font-weight: 800; color: #a9c2ff; font-size: 14px; }
.sq-vote { flex: 0 0 auto; border: 1px solid var(--glass-border); background: rgba(255,255,255,0.06); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 10px; cursor: pointer; }
.sq-vote.voted { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; box-shadow: var(--gloss); }
.sq-member .sq-edit { margin: 10px 0 0; }

.menu { display: flex; flex-direction: column; gap: 8px; }
.menu-row {
  display: flex; align-items: center; gap: 14px; border-radius: 14px; width: 100%;
  color: var(--text); font-size: 16px; text-align: left; text-decoration: none;
  padding: 15px 16px; cursor: pointer;
}
.menu-row > span { flex: 1; }
.menu-row > i:first-child { font-size: 21px; color: #a9c2ff; width: 24px; text-align: center; }
.menu-row .chev { color: var(--muted); font-size: 18px; }
.version { text-align: center; font-size: 12px; margin-top: 22px; }

#screen-loading { text-align: center; padding: 96px 0; }
.spinner { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,0.15); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
