:root {
  --bg: #0f1420;
  --bg-soft: #161d2e;
  --card: #1c2436;
  --line: #2a3350;
  --text: #e7ecf5;
  --muted: #9aa6c0;
  --accent: #4c8dff;
  --accent-2: #6aa6ff;
  --danger: #ff5d6c;
  --radius: 14px;
}

* { box-sizing: border-box; }

html {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #1b2740, transparent), var(--bg);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100%;
}

.hidden { display: none !important; }
code { background: #0c1018; padding: 2px 6px; border-radius: 6px; color: var(--accent-2); }
.muted { color: var(--muted); }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: rgba(15,20,32,.8); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; min-width: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 9px; display: block;
  object-fit: cover; flex-shrink: 0;
  background: #ffd400;
}
.brand-name { font-size: 18px; letter-spacing: .3px; }
.nav { display: flex; gap: 6px; }
.nav-btn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 8px 16px; border-radius: 10px; cursor: pointer; font-size: 14px; transition: .15s;
  display: inline-flex; align-items: center; gap: 5px;
}
.nav-btn:hover { color: var(--text); border-color: var(--accent); }
.nav-btn.active { background: var(--bg-soft); color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 1px rgba(76, 141, 255, 0.25); }

/* Подсветка раздела «Портрет» — акцент только в active */
.nav-btn-featured {
  position: relative;
  color: var(--muted);
  border-color: var(--line);
  background: transparent;
}
.nav-btn-featured:hover { border-color: rgba(255, 196, 56, 0.45); color: var(--text); }
.nav-btn-featured.active {
  color: var(--text);
  border-color: rgba(255, 196, 56, 0.65);
  background: linear-gradient(135deg, rgba(255, 196, 56, 0.14), rgba(76, 141, 255, 0.14));
  box-shadow: 0 0 14px rgba(76, 141, 255, 0.22);
}
.nav-feature-icon {
  font-size: 15px;
  line-height: 1;
  display: inline-block;
  opacity: 0.75;
}
.nav-btn-featured.active .nav-feature-icon {
  opacity: 1;
  animation: nav-spark-pulse 1.6s ease-in-out infinite;
}
.nav-feature-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 2px 5px;
  border-radius: 5px;
  color: #1a1400;
  background: linear-gradient(135deg, #ffd54a, #ffb020);
  box-shadow: 0 0 8px rgba(255, 196, 56, 0.45);
  opacity: 0.7;
}
.nav-btn-featured.active .nav-feature-badge { opacity: 1; animation: nav-badge-pulse 2s ease-in-out infinite; }

@keyframes nav-spark-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 2px #ffc438); }
  50% { transform: scale(1.2) rotate(-8deg); filter: drop-shadow(0 0 7px #ffc438); }
}
@keyframes nav-feature-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 196, 56, 0); }
  50% { box-shadow: 0 0 12px rgba(255, 196, 56, 0.22); }
}
@keyframes nav-badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.user-box { display: flex; align-items: center; position: relative; }
.user-menu-wrap { position: relative; }
.user-avatar-btn {
  width: 38px; height: 38px; padding: 0; border: 2px solid var(--line);
  border-radius: 50%; background: var(--bg-soft); cursor: pointer;
  overflow: hidden; transition: border-color .15s;
}
.user-avatar-btn:hover, .user-avatar-btn[aria-expanded="true"] { border-color: var(--accent); }
.user-avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-avatar-fallback {
  display: grid; place-items: center; width: 100%; height: 100%;
  color: var(--muted); font-weight: 600; font-size: 16px;
}
.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 140px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.35); z-index: 20;
}
.user-menu-item {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  color: var(--text); padding: 10px 12px; border-radius: 8px; cursor: pointer;
  font-size: 14px; text-decoration: none;
}
.user-menu-item:hover { background: var(--bg-soft); color: var(--danger); }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px 80px; }
.screen { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px;
}
.notice h2 { margin-top: 0; }
.hero { text-align: center; padding: 56px 28px; }
.hero h1 { font-size: 30px; margin: 0 0 12px; }
.hero > p { color: var(--muted); max-width: 560px; margin: 0 auto 26px; line-height: 1.5; }
.login-error { color: #f87171; margin-top: 12px; font-size: 14px; }

/* Buttons */
.btn {
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  padding: 10px 16px; border-radius: 10px; cursor: pointer; font-size: 14px;
  transition: .15s; text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #6a7bff); border: none; color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-success { background: linear-gradient(135deg, #22c55e, #16a34a); border: none; color: #fff; font-weight: 600; }
.btn-success:hover { filter: brightness(1.08); }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.toolbar h2 { margin: 0; }
.section-title { margin: 28px 0 14px; font-size: 16px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px; }
.section-title-lg {
  margin: 0 0 16px; font-size: 28px; color: var(--text); font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px; line-height: 1.15;
}
.section-title-spaced { margin-top: 36px; }
.library-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 4px;
}
.library-header .section-title-lg { margin-bottom: 0; }
.library-privacy-notice {
  margin: 0 0 18px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}
.library-privacy-title {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}
.library-privacy-title strong { color: var(--text); font-weight: 600; }
.library-privacy-detail {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.library-support-note {
  margin: 28px 0 8px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.library-legal-links {
  margin: 12px 0 8px;
  text-align: center;
  font-size: 12px;
}
.library-legal-links a { color: var(--accent-2); }
.legal-inline {
  margin-top: 18px;
  font-size: 12px;
  line-height: 1.5;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.legal-inline a { color: var(--accent-2); }
.text-link {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.text-link:hover { color: #9ec0ff; }
.albums-bar { margin-bottom: 16px; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.album {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: .18s;
}
.album:hover { transform: translateY(-3px); border-color: var(--accent); }
.album .cover { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #0c1018; display: block; }
.album .meta { padding: 12px 14px; }
.album .title { font-weight: 600; margin: 0 0 4px; font-size: 15px; }
.album .count { color: var(--muted); font-size: 13px; }
.album.special .cover-fallback {
  width: 100%; aspect-ratio: 4/3; display: grid; place-items: center;
  background: linear-gradient(135deg, #233, #1a2740); font-size: 40px;
}

/* Panel */
.panel { position: fixed; inset: 0; background: rgba(5,8,14,.6); display: grid; place-items: center; z-index: 50; }
.panel-card {
  width: min(520px, 92vw); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px; position: relative;
}
.panel-close { position: absolute; top: 14px; right: 16px; background: none; border: none; color: var(--muted); font-size: 26px; cursor: pointer; }
.panel-card h3 { margin: 0 0 4px; }
.opt { display: flex; align-items: center; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.opt select { background: var(--bg-soft); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-left: auto; }
.panel-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* Stats / визуализация активности */
.stats-hint { margin: -6px 0 18px; }

.stats-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 18px; margin-bottom: 20px; }
.seg-group { display: flex; flex-direction: column; gap: 6px; }
.seg-cap { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.segmented { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg { background: transparent; border: none; color: var(--muted); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: .15s; }
.seg:hover { color: var(--text); }
.seg.active { background: var(--accent); color: #fff; font-weight: 600; }

.stats-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat-peak { cursor: pointer; border-color: var(--accent); }
.stat-peak:hover { background: var(--bg-soft); }
.stat-v { font-size: 20px; font-weight: 700; }
.stat-l { color: var(--muted); font-size: 13px; margin-top: 4px; }

.wave-wrap {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; overflow: hidden;
}
.wave-wrap canvas { display: block; width: 100%; cursor: pointer; }
.wave-tooltip {
  position: absolute; top: 12px; transform: translateX(-50%);
  background: #0c1018; border: 1px solid var(--line); color: var(--text);
  padding: 6px 10px; border-radius: 8px; font-size: 12px; pointer-events: none;
  white-space: nowrap; line-height: 1.4; z-index: 2;
}
.wave-tooltip b { color: var(--accent-2); }

/* Stats: дни недели + список постов */
.stats-grid { display: grid; grid-template-columns: 320px 1fr; gap: 18px; margin-top: 20px; }
@media (max-width: 760px) { .stats-grid { grid-template-columns: 1fr; } }
.stats-grid .card { padding: 18px; }
.stats-grid h4 { margin: 0 0 14px; font-size: 15px; }

.weekday-chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; }
.wd-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.wd-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.wd-bar { width: 100%; min-height: 3px; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, #6aa6ff, #365fb0); transition: height .4s ease; }
.wd-label { color: var(--muted); font-size: 12px; }

.posts-card { min-height: 150px; }
.posts-list { display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow-y: auto; }
.post-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--bg-soft); }
.post-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.post-date { color: var(--muted); font-size: 12px; }
.post-link { font-size: 12px; color: var(--accent-2); text-decoration: none; white-space: nowrap; }
.post-link:hover { text-decoration: underline; }
.post-text { font-size: 14px; line-height: 1.45; word-break: break-word; }
.post-attach { opacity: .7; }
.post-stats { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* Обзор: график роста по годам */
.growth-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 12px; }
.growth-legend .lg { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.growth-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.growth-legend .sw-line { width: 16px; height: 0; border-radius: 0; border-top: 3px solid #ffcf5c; }
.seg-photos { background: linear-gradient(180deg, #6aa6ff, #365fb0); }
.seg-posts { background: linear-gradient(180deg, #8a5cff, #5b3db0); }
.seg-videos { background: linear-gradient(180deg, #3fd2c0, #1f8f86); }
.growth-wrap { position: relative; }
.growth-chart { display: flex; align-items: flex-end; gap: 6px; height: 200px; }
.growth-col { flex: 1; min-width: 0; height: 100%; }
.growth-bar-wrap { height: 100%; width: 100%; display: flex; flex-direction: column-reverse; align-items: stretch; }
.growth-seg { width: 100%; min-height: 0; }
.growth-col .growth-seg:last-child { border-radius: 5px 5px 0 0; }
.growth-col.peak .growth-bar-wrap { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.growth-line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.growth-line .cum-line { fill: none; stroke: #ffcf5c; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.growth-years { display: flex; gap: 6px; margin-top: 6px; }
.growth-year { flex: 1; min-width: 0; text-align: center; color: var(--muted); font-size: 11px; }
.growth-year.peak { color: var(--accent-2); font-weight: 700; }
.growth-peak { margin-top: 14px; font-size: 14px; }
.overview-note { margin-top: 18px; font-size: 13px; line-height: 1.5; }

/* Обзор: состав контента */
.composition { display: flex; flex-direction: column; gap: 10px; }
.comp-row { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 12px; }
.comp-label { color: var(--muted); font-size: 13px; }
.comp-track { background: var(--line); border-radius: 6px; height: 14px; overflow: hidden; }
.comp-bar { height: 100%; border-radius: 6px; }
.comp-val { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.seg-audios { background: linear-gradient(90deg, #ff8a5c, #d65f33); }
.seg-albums { background: linear-gradient(90deg, #f06aa6, #b03570); }
.seg-notes { background: linear-gradient(90deg, #9aa6ff, #5f6bd6); }
.comp-bar.seg-photos, .comp-bar.seg-posts, .comp-bar.seg-videos { background-image: none; }
.comp-bar.seg-photos { background: #5a86d8; }
.comp-bar.seg-posts { background: #7a5cd8; }
.comp-bar.seg-videos { background: #2faaa0; }

/* Обзор: демография друзей */
.friends-demo { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.card.sub { background: var(--panel-2, rgba(255,255,255,.02)); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.card.sub h5 { margin: 0 0 12px; font-size: 14px; }
.sex-bar { display: flex; height: 18px; border-radius: 6px; overflow: hidden; background: var(--line); }
.sex-bar span { height: 100%; }
.sex-f { background: #f06aa6; }
.sex-m { background: #5a86d8; }
.sex-u { background: #6a6a76; }
.sex-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.sex-legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: 6px; }
.age-chart { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.age-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.age-bar { width: 100%; min-height: 2px; background: linear-gradient(180deg, #6aa6ff, #365fb0); border-radius: 4px 4px 0 0; }
.age-lbl { color: var(--muted); font-size: 11px; white-space: nowrap; }
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 1fr 90px 48px; align-items: center; gap: 10px; }
.rank-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { background: var(--line); border-radius: 5px; height: 10px; overflow: hidden; }
.rank-bar { display: block; height: 100%; background: linear-gradient(90deg, #6aa6ff, #365fb0); border-radius: 5px; }
.rank-val { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }

/* Глобальный оверлей загрузки */
body.loading-active { overflow: hidden; }
.loading-overlay {
  position: fixed; inset: 0; z-index: 45;
  display: grid; place-items: center;
  background: rgba(8, 12, 20, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
}
.loading-overlay--visible { opacity: 1; pointer-events: auto; }
.loading-card {
  text-align: center; padding: 32px 36px; min-width: min(320px, 88vw);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 48px rgba(0, 0, 0, .35);
  transform: translateY(10px) scale(.97);
  opacity: 0;
  animation: loading-card-in .35s ease forwards;
}
.loading-spinner {
  width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .85s linear infinite;
}
.loading-title {
  margin: 0 0 6px; font-size: 17px; font-weight: 600;
  animation: loading-pulse 1.6s ease-in-out infinite;
}
.loading-detail {
  margin: 0; font-size: 14px; color: var(--muted); line-height: 1.45;
  min-height: 1.2em;
}
.loading-progress {
  margin-top: 16px;
  width: min(260px, 70vw);
  margin-left: auto;
  margin-right: auto;
}
.loading-progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  overflow: hidden;
}
.loading-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8a5cff);
  transition: width .25s ease;
}

/* Pull-to-refresh */
.ptr-indicator {
  position: fixed;
  top: 8px;
  left: 50%;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(28, 36, 54, 0.94);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-12px + 18px * var(--ptr, 0))) scale(calc(0.92 + 0.08 * var(--ptr, 0)));
  transition: opacity .15s ease;
}
.ptr-indicator--visible { opacity: 1; }
.ptr-indicator--ready { color: var(--text); border-color: var(--accent); }
.ptr-indicator--busy .ptr-spinner { animation: spin .85s linear infinite; }
.ptr-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loading-card-in {
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes loading-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .72; }
}

/* AI-портрет */
.ai-privacy-block { margin-top: 16px; display: grid; gap: 10px; }
.ai-privacy { margin: 0; font-size: 13px; line-height: 1.55; }
.ai-privacy strong { color: var(--text); font-weight: 600; }
.ai-support-note { padding: 12px 14px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; }
.ai-data-notice { margin-top: 10px; font-size: 12px; color: #b8c4dc; }
.ai-share .ai-data-notice { margin-top: 0; margin-bottom: 8px; max-width: 420px; margin-left: auto; margin-right: auto; }
.ai-spinner {
  width: 44px; height: 44px; margin: 8px auto 16px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite;
}
#ai-loading { text-align: center; padding: 36px; }

.ai-tiers {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin: 22px 0 8px; text-align: left;
}
@media (max-width: 700px) { .ai-tiers { grid-template-columns: 1fr; } }
.ai-tier {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.ai-tier-deep { border-color: #3d5a9a; }
.ai-tier h3 { margin: 0; font-size: 17px; }
.ai-tier-desc { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; flex: 1; }
.ai-tier-badge {
  display: inline-block; width: fit-content; font-size: 11px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent-2); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px;
}
.ai-tier-badge-deep { color: #c9b6ff; border-color: #4a3d7a; }
.ai-tier-price {
  display: flex; align-items: baseline; gap: 10px; margin: 6px 0 2px;
  font-size: 22px; font-weight: 700;
}
.ai-tier-price .muted { font-size: 13px; font-weight: 400; }
.ai-tier-model { margin: 0 0 6px; font-size: 12px; word-break: break-all; }
.ai-tier .btn { width: 100%; margin-top: 4px; }

.ai-estimate {
  margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line);
}
.ai-estimate-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
  margin-bottom: 10px; font-size: 13px;
}
.ai-estimate-row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 6px 8px; background: rgba(0,0,0,.18); border-radius: 8px;
}
.ai-estimate-row strong { font-weight: 600; }

.ai-archetypes { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.archetype {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  background: linear-gradient(135deg, rgba(76,141,255,.18), rgba(138,92,255,.18));
  border: 1px solid var(--line); border-radius: 999px; font-weight: 600; font-size: 15px;
}
.arch-emoji { font-size: 22px; }

.ai-summary { font-size: 17px; line-height: 1.6; margin-bottom: 22px; }
.ai-summary p { margin: 0; }

.ai-timeline { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.period-card { display: flex; gap: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.period-when {
  flex: 0 0 110px; font-weight: 700; color: var(--accent-2); font-size: 15px;
  border-right: 1px solid var(--line); padding-right: 16px;
}
.period-body { flex: 1; }
.period-title { font-weight: 600; font-size: 16px; margin-bottom: 6px; }
.period-desc { color: var(--text); line-height: 1.55; }
.period-themes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.theme-chip { background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted); font-size: 12px; padding: 3px 10px; border-radius: 999px; }

.ai-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
@media (max-width: 700px) { .ai-extra { grid-template-columns: 1fr; } .period-card { flex-direction: column; gap: 8px; } .period-when { border-right: none; border-bottom: 1px solid var(--line); padding: 0 0 8px; } }
.ai-extra h4 { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.ai-extra p { margin: 0; line-height: 1.55; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 12px; }
.ai-actions-single { justify-content: center; }
.ai-return-bar { text-align: center; margin: 0 0 20px; padding: 14px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; }
.ai-return-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.ai-share { margin: 0 0 14px; text-align: center; }
.ai-share-title { margin: 0 0 16px; font-size: 1.35rem; font-weight: 600; letter-spacing: 0.01em; }
.ai-share-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ai-share-hint { margin: 14px auto 0; font-size: 12px; max-width: 420px; }
.ai-disclaimer { font-size: 12px; }

/* Progress */
.progress { margin-top: 18px; }
.progress-bar { width: 100%; height: 8px; background: var(--bg-soft); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #8a5cff); transition: width .2s; }
.progress-text { color: var(--muted); font-size: 13px; margin-top: 8px; }

/* ===== Мобильная адаптация ===== */
@media (max-width: 720px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand user"
      "nav nav";
    gap: 10px 8px;
    padding: 10px 12px;
    align-items: center;
  }
  .brand { grid-area: brand; }
  .brand-name { display: none; }
  .logo { width: 36px; height: 36px; border-radius: 10px; }
  .nav {
    grid-area: nav;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
    min-width: 0;
  }
  .nav-btn {
    justify-content: center;
    width: 100%;
    min-width: 0;
    padding: 9px 8px;
    font-size: 13px;
    white-space: nowrap;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted);
    box-shadow: none;
  }
  .nav-btn.active {
    color: var(--text);
    border-color: var(--accent);
    background: var(--bg-soft);
    box-shadow: 0 0 0 1px rgba(76, 141, 255, 0.28);
  }
  .nav-btn-featured:not(.active) {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted);
  }
  .nav-btn-featured.active {
    border-color: rgba(255, 196, 56, 0.7);
    background: linear-gradient(135deg, rgba(255, 196, 56, 0.16), rgba(76, 141, 255, 0.14));
  }
  .nav-feature-badge { display: none; }
  .nav-feature-icon { font-size: 14px; }
  .user-box { grid-area: user; justify-self: end; }
  .user-avatar-btn { width: 36px; height: 36px; }

  .container {
    padding: 16px 12px 72px;
    width: 100%;
    max-width: 100%;
  }

  .card { padding: 16px; }
  .hero { padding: 36px 16px; }
  .hero h1 { font-size: 24px; }

  .toolbar {
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
  }
  .toolbar h2 {
    font-size: 20px;
    line-height: 1.25;
    min-width: 0;
    flex: 1 1 auto;
  }
  .section-title-lg {
    font-size: 18px;
    letter-spacing: .4px;
  }
  .library-header {
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
  }

  /* Превью альбомов ≈ в 2 раза меньше: 2 колонки вместо одной широкой */
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .album { border-radius: 12px; }
  .album:hover { transform: none; }
  .album .meta { padding: 8px 9px; }
  .album .title {
    font-size: 12px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .album .count { font-size: 11px; }
  .album.special .cover-fallback { font-size: 28px; }

  .stats-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .seg-group { width: 100%; min-width: 0; }
  .segmented {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
  }
  .seg {
    flex: 1 1 auto;
    text-align: center;
    padding: 8px 10px;
    min-width: 0;
  }

  .stats-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .stat-card { padding: 12px; min-width: 0; }
  .stat-v { font-size: 16px; word-break: break-word; }
  .stat-l { font-size: 12px; line-height: 1.35; }

  .wave-wrap { padding: 10px; }
  .wave-tooltip {
    white-space: normal;
    max-width: calc(100% - 16px);
    left: 50% !important;
    transform: translateX(-50%);
  }

  .comp-row {
    grid-template-columns: 72px minmax(0, 1fr) 48px;
    gap: 8px;
  }
  .comp-label { font-size: 12px; }
  .rank-row {
    grid-template-columns: minmax(0, 1fr) 64px 40px;
    gap: 8px;
  }

  .friends-demo { grid-template-columns: 1fr; }
  .growth-chart { height: 160px; gap: 3px; }
  .growth-years { gap: 3px; }
  .growth-year { font-size: 9px; }

  .ai-tier-price { font-size: 18px; flex-wrap: wrap; }
  .ai-estimate-grid { grid-template-columns: 1fr; }
  .ai-actions { flex-direction: column; }
  .ai-actions .btn { width: 100%; text-align: center; }
  .archetype { width: 100%; justify-content: flex-start; border-radius: 12px; }

  .panel-card { width: min(520px, calc(100vw - 24px)); padding: 20px 16px; }
  .opt { flex-direction: column; align-items: stretch; }
  .opt select { margin-left: 0; width: 100%; }
  .panel-actions { flex-wrap: wrap; }

  .library-privacy-notice,
  .library-support-note { padding: 12px; }
  .library-legal-links { font-size: 11px; line-height: 1.6; }
}
