@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: dark;
  /* Основные цвета */
  --color-tiktok-cyan: rgb(110, 207, 203);
  --color-tiktok-pink: rgb(237, 29, 81);

  /* Градиенты */
  --header-gradient: linear-gradient(
    to right in oklab,
    var(--color-tiktok-cyan) 0%,
    #ffffff 50%,
    var(--color-tiktok-pink) 100%
  );
  --primary-gradient: linear-gradient(
    90deg,
    var(--color-tiktok-cyan),
    var(--color-tiktok-pink)
  );

  /* Палитра */
  --bg-body: #050505;
  --bg-card: #121212;
  --bg-element: #1e1e1e;
  --bg-element-hover: #2c2c2c;

  /* Текст */
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  /* Границы */
  --border-color: #333333;
  --border-radius-large: 24px;
  --border-radius-medium: 12px;
  --font-main: "Inter", sans-serif;
}

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

html,
body {
  font-family: var(--font-main);
  background-color: var(--bg-body) !important;
  /* ХАК ДЛЯ SAMSUNG: Фон задан как градиент, чтобы браузер не инвертировал цвета */
  background-image: radial-gradient(
      circle at 15% 50%,
      rgba(110, 207, 203, 0.08),
      transparent 25%
    ),
    radial-gradient(circle at 85% 30%, rgba(237, 29, 81, 0.08), transparent 25%),
    linear-gradient(#050505, #050505) !important;
  color: var(--text-primary);
  line-height: 1.6;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 20px 5px;
  forced-color-adjust: none;
}

/* --- SITE NAVIGATION --- */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 15px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  background: rgba(5, 5, 5, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.nav-logo {
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
#mainContent,
#mainResults {
  margin-top: 60px;
}

/* --- CONTAINER --- */
.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  background-color: transparent;
  border: none;
  box-shadow: none;
}

/* --- BUTTONS (SAMSUNG FIX) --- */
button,
.modal-button {
  padding: 14px 32px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.2s;
}

/* Primary */
#startButton,
#haveFileButton,
.modal-button[href],
#showSlideshowButton {
  /* Хак: используем image вместо color */
  background-image: var(--primary-gradient) !important;
  background-size: 200% auto;
  color: #000 !important;
  box-shadow: 0 4px 15px rgba(237, 29, 81, 0.3);
}
#startButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(110, 207, 203, 0.4);
}

/* Secondary */
.secondary-button,
#demoButton,
#resetButton,
#shareImageButton {
  background-image: linear-gradient(
    var(--bg-element),
    var(--bg-element)
  ) !important; /* Хак */
  background-color: transparent !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color);
}

/* --- LANDING PAGE --- */
.hero-section {
  text-align: center;
  padding: 40px 0 60px;
  position: relative;
}
.hero-badge {
  display: inline-block;
  background: rgba(46, 204, 113, 0.15);
  color: #2ecc71;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 20px;
  border: 1px solid rgba(46, 204, 113, 0.3);
}
h1 {
  font-size: 4rem;
  max-width: 900px;
  margin: 0 auto 15px;
  line-height: 1.1;
}
.hero-desc {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 30px;
}
.header-buttons {
  margin-top: 35px;
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

/* Hero Visual */
.hero-visual {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 50px;
  perspective: 1000px;
  opacity: 0.8;
}
.visual-card {
  width: 120px;
  height: 140px;
  background: linear-gradient(135deg, #1e1e1e, #111);
  border: 1px solid #333;
  border-radius: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  color: #555;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: rotateX(20deg);
}
.v-persona {
  background: linear-gradient(135deg, #2b1055, #000);
  color: white;
  transform: rotateX(20deg) translateY(10px) rotateZ(-5deg);
  z-index: 2;
}
.v-hours {
  background: linear-gradient(135deg, #111, #1a1a1a);
  color: var(--color-tiktok-cyan);
  font-size: 1.5rem;
  transform: rotateX(20deg) scale(1.1);
  z-index: 3;
  border-color: var(--color-tiktok-cyan);
}
.v-graph {
  transform: rotateX(20deg) translateY(10px) rotateZ(5deg);
  z-index: 1;
  flex-direction: row;
  align-items: flex-end;
  padding-bottom: 30px;
  gap: 5px;
}
.v-graph span {
  width: 8px;
  background: #333;
  border-radius: 2px;
}
.v-graph span:nth-child(2) {
  height: 40px;
  background: var(--color-tiktok-pink);
}

/* Features & Steps */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 60px 0;
}
.feature-item {
  background: rgba(255, 255, 255, 0.03);
  padding: 25px;
  border-radius: 20px;
  text-align: left;
}
.feat-icon {
  font-size: 2rem;
  margin-bottom: 15px;
}
.feature-item h3 {
  color: white;
  margin-bottom: 10px;
  font-weight: 700;
}

.steps-section {
  text-align: center;
  margin: 80px 0;
  padding: 40px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  border-radius: 30px;
}
.steps-row {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  margin-top: 40px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}
.step-card {
  flex: 1;
  min-width: 200px;
}
.step-num {
  width: 40px;
  height: 40px;
  background: var(--bg-element);
  color: var(--color-tiktok-cyan);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 15px;
  border: 2px solid var(--border-color);
  font-weight: 800;
}

/* FAQ */
.faq h2 {
  text-align: center;
  margin-bottom: 40px;
}

.faq-item {
  background: var(--bg-element);
  border-radius: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.faq-item summary {
  padding: 20px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
}
.faq-item summary::after {
  content: "+";
  font-size: 1.5rem;
  color: var(--text-secondary);
  transition: 0.3s;
}
.faq-item[open] summary::after {
  transform: rotate(45deg);
  color: var(--color-tiktok-pink);
}
.faq-content {
  padding: 20px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  text-align: left;
}

/* --- BENTO GRID DASHBOARD --- */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  flex-wrap: wrap;
  gap: 20px;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 20px;
}
.user-details h2 {
  font-size: 2rem;
  margin: 0;
  line-height: 1;
}
.res-year-badge,
.res-range-badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.res-range-badge {
  background: rgba(244, 208, 63, 0.15);
  color: #f4d03f;
  border: 1px solid rgba(244, 208, 63, 0.3);
}

/* Avatar */
.user-avatar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  position: relative;
}
.user-avatar-ring {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #1a1a1a;
}
.user-avatar-ring::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(
    var(--color-tiktok-cyan),
    #a600f4,
    var(--color-tiktok-pink),
    #f09433,
    var(--color-tiktok-cyan)
  );
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  z-index: 2;
  transition: filter 0.3s ease;
}
.user-avatar-container:hover .user-avatar-ring::before {
  animation: spinRing 2s linear infinite;
  filter: brightness(1.3);
}
@keyframes spinRing {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.user-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #121212;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 3;
  border: 4px solid var(--bg-card);
  overflow: hidden;
}
#resAvatarImg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 5;
}
#resAvatarInitials {
  position: relative;
  z-index: 1;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, #ffffff 0%, #b0b0b0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0;
  padding: 0;
}
.story-label {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--color-tiktok-pink);
  font-weight: 700;
  text-transform: uppercase;
}

/* Grid Layout */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(240px, auto);
  gap: 20px;
}

.bento-card {
  /* Хак для Samsung: Image вместо Color */
  background-image: linear-gradient(var(--bg-card), var(--bg-card)) !important;
  background-color: transparent !important;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 25px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  position: relative;
  overflow: hidden;
}
.card-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 15px;
}

/* 1. Persona */
.card-persona {
  grid-column: span 2;
  background-image: linear-gradient(
    135deg,
    #1e1e1e 0%,
    #0d0d0d 100%
  ) !important;
}
.persona-title {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 5px;
  background: var(--header-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.persona-desc {
  font-size: 1rem;
  color: #ccc;
  line-height: 1.4;
}
.persona-superpower {
  background: rgba(255, 255, 255, 0.08);
  padding: 15px;
  border-radius: 16px;
  margin-top: 10px;
}
.superpower-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
}
.superpower-value::before {
  content: "⚡";
}

/* 2. Hero */
.card-hero {
  grid-column: span 2;
  background-image: linear-gradient(
    135deg,
    #121212 0%,
    #1e1e1e 100%
  ) !important;
}
.hero-value {
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 1;
  margin: 5px 0;
  letter-spacing: -2px;
}
.hero-value small {
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text-muted);
}
.hero-footer-grid {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.hero-stat-item {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero-stat-item.highlight {
  background: rgba(110, 207, 203, 0.1);
  border: 1px solid rgba(110, 207, 203, 0.2);
}
.stat-num {
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

/* 3. Peak */
.card-peak {
  grid-column: span 2;
  background-image: linear-gradient(
    135deg,
    #1a2980 0%,
    #26d0ce 100%
  ) !important;
}
.peak-value {
  font-size: 2.5rem;
  font-weight: 800;
  margin-top: 5px;
}
.months-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
  margin-top: auto;
}
.month-bar {
  flex: 1;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  min-height: 2px;
}
.month-bar.active {
  background: #fff;
}

/* 4. Ratio */
.card-ratio {
  grid-column: span 1;
  align-items: center;
  text-align: center;
}
.ratio-circle {
  width: 110px;
  height: 110px;
  margin: auto;
  position: relative;
}
.circular-chart {
  display: block;
  max-width: 100%;
  max-height: 100%;
}
.circle-bg {
  fill: none;
  stroke: #333;
  stroke-width: 2.5;
}
.circle {
  fill: none;
  stroke: var(--color-tiktok-pink);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: 1s ease-out;
}
.ratio-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  font-weight: 700;
}

/* 5. Night */
.card-night {
  grid-column: span 1;
  background-image: linear-gradient(
    180deg,
    #090910 0%,
    #2b1055 100%
  ) !important;
  align-items: center;
  text-align: center;
  justify-content: center;
}
.night-icon {
  font-size: 3rem;
  color: #f4d03f;
  margin: 15px 0;
}
.night-val {
  font-size: 2.5rem;
  font-weight: 700;
}

/* 6. General Stats */
.card-general-stats {
  grid-column: span 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  padding: 20px;
}
.gen-stat-item {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gen-stat-item i {
  margin-bottom: 5px;
  opacity: 0.8;
}
.gen-stat-item span {
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

/* 7. Comments */
.card-comments-split {
  grid-column: span 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.comm-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.emoji-val {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 5px;
}
.comm-val {
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
}
.comm-divider {
  height: 1px;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  margin: 10px 0;
}

/* 8. Chart */
.card-chart {
  grid-column: span 2;
  height: auto;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  padding-bottom: 25px;
}
.chart-container {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  gap: 3px;
  height: 160px;
  position: relative;
  margin-top: auto;
}
.chart-bar {
  background: var(--bg-element);
  border-radius: 4px 4px 0 0;
  flex: 1;
  transition: height 1s;
  min-height: 6px;
  position: relative;
}
.chart-bar:hover {
  background: var(--color-tiktok-cyan);
}
.chart-bar:hover::after {
  content: attr(data-hour);
  position: absolute;
  top: -35px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  background: #000;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
}

/* --- TABLE --- */
.table-responsive-wrapper {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 30px;
}
#statsTable {
  width: 100%;
  border-collapse: collapse;
}
#statsTable th,
#statsTable td {
  padding: 18px 25px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}
#statsTable thead th {
  background: var(--bg-element);
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 1px;
}
.group-header td {
  background: #252525;
  color: var(--color-tiktok-cyan);
  font-size: 1.1rem;
}

/* --- MODALS --- */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  overflow-y: auto;
  align-items: center;
  justify-content: center;
  padding: 10px;
}
.modal[style*="display: block"] {
  display: flex !important;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  width: 100%;
  max-width: 600px;
  padding: 40px;
  margin: auto;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.year-select-container {
  margin-bottom: 25px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
}
#yearSelect {
  padding: 12px 20px;
  font-size: 1.1rem;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background-image: linear-gradient(#1e1e1e, #1e1e1e) !important;
  background-color: transparent !important;
  color: white !important;
  cursor: pointer;
  outline: none;
}
.upload-area {
  /* 1. Превращаем label в блочный Flex-контейнер */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;

  /* 2. Размеры и отступы */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 50px 20px;
  margin: 20px 0;

  /* 3. Визуал */
  background: var(--bg-element);
  border: 2px dashed var(--border-color);
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--color-tiktok-cyan);
  background: rgba(110, 207, 203, 0.05);
  transform: scale(1.01);
}

.upload-icon {
  font-size: 3.5rem;
  color: var(--text-muted);
  margin-bottom: 15px;
  transition: color 0.3s;
}

.upload-area:hover .upload-icon {
  color: var(--color-tiktok-pink);
}
#uploadStatus {
  margin-top: 20px;
  padding: 15px;
  border-radius: 8px;
  display: none;
  font-weight: 500;
}
.status-loading {
  background: rgba(110, 207, 203, 0.1);
  color: var(--color-tiktok-cyan);
}
.status-error {
  background: rgba(237, 29, 81, 0.1);
  color: var(--color-tiktok-pink);
}

/* --- FULLSCREEN SLIDESHOW --- */
#fullscreenSlideshow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
  overflow: hidden; /* Важно: чтобы не было скролла */
}

#fullscreenSlideshow.visible {
  opacity: 1;
  pointer-events: auto;
}

.fs-slides-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.fs-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 20px; /* Безопасные отступы */
  opacity: 0;
  transform: scale(0.95);
  transition: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.fs-slide.active {
  opacity: 1;
  transform: scale(1);
  z-index: 10;
}

/* АДАПТИВНАЯ ТИПОГРАФИКА (clamp) */

/* Заголовок (сверху) */
.fs-title {
  font-size: clamp(1.2rem, 3vh, 2rem); /* Масштабируется от высоты */
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-secondary);
  margin-bottom: 2vh;
}

/* Огромная цифра */
.fs-value {
  font-size: clamp(
    3.5rem,
    12vw,
    7rem
  ); /* Чуть уменьшил минимум, чтобы влезало */
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 2vh;

  background: var(--header-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);

  /* ИСПРАВЛЕНИЕ ПЕРЕНОСОВ */
  word-break: normal; /* Не рвать слова посередине */
  overflow-wrap: break-word; /* Переносить только если слово шире экрана (редко) */
  text-align: center;

  max-width: 95vw;
}

/* Подпись */
.fs-label {
  font-size: clamp(1.2rem, 4vw, 2.5rem);
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 4vh;
}

/* Детали (Текст снизу) */
.fs-details {
  font-size: clamp(1rem, 3.5vw, 1.5rem);
  color: var(--text-secondary);
  max-width: 800px;
  width: 90%; /* Чтобы не прилипало к краям на телефоне */
  background: rgba(255, 255, 255, 0.05);
  padding: 20px;
  border-radius: 20px;
  backdrop-filter: blur(5px);
  line-height: 1.5;
}

/* Кнопка закрытия */
.close-fs-button {
  position: absolute;
  top: 20px;
  right: 20px;

  /* Жесткие размеры */
  width: 50px;
  height: 50px;
  min-width: 50px; /* Чтобы не сплющивалась */
  min-height: 50px;
  padding: 0; /* Убираем внутренние отступы */

  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  font-size: 1.5rem;

  cursor: pointer;
  z-index: 10000;

  /* Центрируем крестик */
  display: flex;
  justify-content: center;
  align-items: center;

  margin-top: env(safe-area-inset-top);
  transition: background 0.3s;
}

.close-fs-button:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Прогресс бар */
.fs-progress-bar-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 10000;
  /* Учитываем "челку" - сдвигаем ниже, если надо, или оставляем сверху */
  top: env(safe-area-inset-top);
}
.fs-progress-bar {
  height: 100%;
  background: var(--primary-gradient);
  width: 0%;
}
/* Спойлер с инструкцией */
.instruction-spoiler {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  text-align: left;
}

.instruction-spoiler summary {
  padding: 15px 5px;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-tiktok-cyan); /* Выделяем цветом как ссылку */
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  font-size: 0.95rem;
}

.instruction-spoiler summary i {
  transition: transform 0.3s;
}

.instruction-spoiler[open] summary i {
  transform: rotate(180deg);
}

.spoiler-content {
  padding: 10px 5px 20px;
  animation: fadeIn 0.3s;
}

.spoiler-content ol {
  margin-left: 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}
.card-persona,
.card-hero {
  position: relative;
}

/* Общий стиль для иконок */
.persona-icon,
.hero-icon {
  position: absolute; /* Вырываем из потока */
  top: 25px; /* Отступ сверху (как у padding карточки) */
  right: 25px; /* Отступ справа */
  font-size: 2rem;
  line-height: 1;
  margin: 0; /* Убираем старые отступы */
  opacity: 1; /* Убеждаемся, что их видно */
}

/* Корректируем заголовок, чтобы он не наезжал на иконку (если текст будет длинным) */
.card-header-row {
  display: block; /* Больше не нужен flex space-between */
  padding-right: 40px; /* Безопасная зона для иконки */
  width: 100%;
}

footer {
  border-top: 1px solid var(--border-color);
  padding-top: 30px;
  margin-top: 100px; /* Добавили большой отступ сверху */
  color: var(--text-muted);
  text-align: center;
  padding-bottom: 40px; /* Чтобы на мобилках было место снизу */
}

/* --- TIKTOK SLIDES GENERATION --- */
.tiktok-slide {
  width: 1080px;
  height: 1920px;
  position: relative;
  overflow: hidden;
  font-family: "Inter", sans-serif;
  color: white;
  display: flex;
  flex-direction: column;
}

/* Фон для всех слайдов */
.slide-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, #1a1a1a 0%, #000 70%);
}
.slide-bg::after {
  content: "";
  position: absolute;
  top: -20%;
  left: -20%;
  width: 80%;
  height: 50%;
  background: var(--color-tiktok-cyan);
  filter: blur(300px);
  opacity: 0.2;
}
.slide-bg::before {
  content: "";
  position: absolute;
  bottom: -20%;
  right: -20%;
  width: 80%;
  height: 50%;
  background: var(--color-tiktok-pink);
  filter: blur(300px);
  opacity: 0.2;
}

.slide-content {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 100px;
}
.slide-content.centered {
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* Типографика слайдов */
.s-year {
  font-size: 4rem;
  font-weight: 800;
  color: #666;
  margin-bottom: 20px;
}
.s-title {
  font-size: 8rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  margin-bottom: 40px;
}
.s-user {
  font-size: 3rem;
  color: var(--color-tiktok-cyan);
}

.s-label {
  font-size: 3rem;
  text-transform: uppercase;
  letter-spacing: 5px;
  color: #888;
  margin-bottom: 40px;
}
.s-big-val {
  font-size: 12rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 50px currentColor;
}
.s-sub {
  font-size: 2.5rem;
  color: #ccc;
  margin-top: 30px;
}

.s-persona {
  font-size: 7rem;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 40px;
}
.s-desc {
  font-size: 2.5rem;
  line-height: 1.5;
  color: #ddd;
}

.s-link-box {
  font-size: 5rem;
  font-weight: 800;

  /* Черный фон как на кнопке "Поделиться" */
  background: #000000;
  border: 3px solid #222; /* Еле заметная рамка */

  padding: 40px 80px;
  border-radius: 100px;

  /* Белый цвет текста по умолчанию */
  color: #ffffff;
  white-space: nowrap;
}

.color-pink {
  color: var(--color-tiktok-pink);
}
.color-cyan {
  color: var(--color-tiktok-cyan);
}

/* --- Стили для Слайдов (Обновленные) --- */
.tiktok-slide {
  width: 1080px;
  height: 1920px;
  position: relative;
  overflow: hidden;
  background: #050505;
  color: white;
  font-family: "Inter", sans-serif;
  display: flex;
  flex-direction: column;
}

/* Фон (Градиенты) */
.slide-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(circle at 50% 50%, #121212 0%, #000 80%);
}
.slide-bg::after {
  content: "";
  position: absolute;
  top: -10%;
  left: -20%;
  width: 1000px;
  height: 1000px;
  background: radial-gradient(
    circle,
    rgba(110, 207, 203, 0.15) 0%,
    transparent 70%
  );
}
.slide-bg::before {
  content: "";
  position: absolute;
  bottom: -10%;
  right: -20%;
  width: 1000px;
  height: 1000px;
  background: radial-gradient(
    circle,
    rgba(237, 29, 81, 0.15) 0%,
    transparent 70%
  );
}

/* Хедер (Никнейм сверху) */
.slide-header {
  position: absolute;
  top: 60px;
  width: 100%;
  text-align: center;
  font-size: 2.5rem;
  font-weight: 600;
  color: #888;
  z-index: 5;
  letter-spacing: 2px;
}

/* Футер (Ссылка снизу) */
.slide-footer {
  position: absolute;
  bottom: 80px;
  width: 100%;
  display: flex;
  justify-content: center;
  z-index: 10;
}

.s-footer-pill {
  background: #000;
  border: 2px solid #222;
  padding: 15px 50px;
  border-radius: 100px;
  font-size: 2rem;
  font-weight: 700;
  color: white;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  letter-spacing: 1px;
}

.slide-content {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 80px;
}
.slide-content.centered {
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* Типографика */
.s-year-huge {
  font-size: 14rem;
  font-weight: 900;
  line-height: 1;
  color: #222;
  margin-bottom: -40px;
}
.s-title-main {
  font-size: 9rem;
  font-weight: 900;
  line-height: 0.9;
  text-transform: uppercase;
  color: white;
  text-shadow: 0 0 50px rgba(255, 255, 255, 0.2);
  margin-bottom: 50px;
}
.s-user-badge {
  font-size: 3.5rem;
  background: #222;
  padding: 20px 60px;
  border-radius: 100px;
  color: var(--color-tiktok-cyan);
  font-weight: 700;
}

.s-label {
  font-size: 3rem;
  text-transform: uppercase;
  letter-spacing: 6px;
  color: #666;
  margin-bottom: 40px;
  font-weight: 700;
}
.s-big-val {
  font-size: 13rem;
  font-weight: 900;
  line-height: 1;
}
.s-sub {
  font-size: 3rem;
  color: #aaa;
  margin-top: 10px;
  font-weight: 500;
}

/* Комментарий (Смешной текст) */
.s-comment {
  font-size: 2.8rem;
  line-height: 1.4;
  color: #eee;
  margin-top: 60px;
  max-width: 900px;
  background: rgba(255, 255, 255, 0.1);
  padding: 40px;
  border-radius: 40px;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.s-persona {
  font-size: 8rem;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 40px;
  text-shadow: 0 0 40px rgba(255, 255, 255, 0.2);
}
.s-desc {
  font-size: 2.8rem;
  line-height: 1.5;
  color: #ccc;
  max-width: 900px;
}

.s-link-box {
  font-size: 5rem;
  font-weight: 800;
  color: white;
}

.color-pink {
  color: var(--color-tiktok-pink);
}
.color-cyan {
  color: var(--color-tiktok-cyan);
}
.color-purple {
  color: #a600f4;
}

/* На мобильных зона загрузки чуть компактнее */
@media (max-width: 600px) {
  .upload-area {
    padding: 30px 15px; /* Уменьшаем высоту, чтобы влезало */
    margin: 10px 0;
  }
  .modal-content {
    padding: 25px 20px;
  }
}

/* =========================================
   MEDIA QUERIES (CLEAN & CONSOLIDATED)
   ========================================= */

/* 1. TABLET (max-width: 1024px) */
@media (max-width: 1024px) {
  .container {
    max-width: 95%;
    padding: 20px 10px;
  }

  .bento-grid {
    grid-template-columns: 1fr 1fr; /* 2 колонки */
    grid-auto-rows: minmax(220px, auto);
  }

  /* Карточки на всю ширину (2 из 2) */
  .card-persona,
  .card-hero,
  .card-peak,
  .card-chart {
    grid-column: span 2;
  }
  /* Карточки по одной (1 из 2) */
  .card-ratio,
  .card-night,
  .card-general-stats,
  .card-comments-split {
    grid-column: span 1;
  }

  .hero-value {
    font-size: 4rem;
  }
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 2. MOBILE (max-width: 700px) */
@media (max-width: 700px) {
  /* --- ОТСТУПЫ (Максимально широко) --- */
  #mainContent,
  #mainResults {
    margin-top: 55px;
  }
  .container {
    padding: 5px;
  } /* Минимальный отступ от краев экрана */

  /* --- HERO LANDING --- */
  .hero-section {
    padding-top: 10px;
    padding-bottom: 20px;
    min-height: auto;
  }
  .hero-visual {
    display: none !important;
  }
  h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    padding: 0 5px;
  }
  .hero-desc {
    font-size: 0.95rem;
    margin-bottom: 20px;
  }

  /* Кнопки на главной (оставляем друг под другом, так удобнее для пальца) */
  .header-buttons {
    flex-direction: column;
    width: 100%;
    padding: 0 5px;
    gap: 10px;
    margin: 0;
  }
  #startButton,
  #demoButton {
    width: 100%;
    margin: 0;
    padding: 14px;
  }

  /* --- HEADER & USER INFO --- */
  .site-nav {
    padding: 10px 15px;
  }
  .dashboard-header {
    flex-direction: column;
    text-align: center;
    margin-bottom: 20px;
  }
  .user-info {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }
  .user-details h2 {
    font-size: 1.6rem;
    word-break: break-all;
  }
  .badges-row {
    justify-content: center;
  }

  /* --- КНОПКИ ДЕЙСТВИЙ (В РЯД) --- */
  .header-actions {
    width: 100%;
    display: flex; /* Включаем флекс */
    flex-direction: row; /* Строго в ряд */
    justify-content: center;
    gap: 10px; /* Небольшой зазор */
    margin-top: 15px;
    padding: 0 5px;
  }

  .action-btn {
    flex: 1; /* Растягиваем кнопки равномерно */
    padding: 12px 5px; /* Уменьшаем внутренние отступы */
    font-size: 0.85rem; /* Чуть меньше шрифт */
    white-space: nowrap; /* Запрещаем перенос текста на кнопке */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
  }

  /* --- BENTO GRID (1 COLUMN) --- */
  .bento-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-auto-rows: auto !important;
    gap: 12px !important;
  }

  /* Карточки */
  .bento-card,
  .card-persona,
  .card-hero,
  .card-peak,
  .card-chart,
  .card-ratio,
  .card-night,
  .card-general-stats,
  .card-comments-split {
    grid-column: span 1 !important;
    width: 100% !important;
    min-height: auto !important;
    padding: 20px 15px !important; /* Уменьшаем паддинг внутри карточек */
  }

  /* --- CARD FIXES --- */
  .card-header-row {
    justify-content: center !important;
  }
  .persona-icon {
    display: none !important;
  }
  .card-label {
    text-align: center;
    width: 100%;
  }
  .persona-content {
    text-align: center;
    align-items: center;
  }

  .persona-title {
    font-size: 1.8rem !important;
    word-wrap: break-word !important;
    line-height: 1.1;
    margin-top: 5px;
  }
  .persona-superpower {
    width: 100%;
    margin-top: 15px;
  }
  .superpower-value {
    justify-content: center;
  }

  .card-hero {
    text-align: center;
  }
  .hero-icon {
    display: none;
  }
  .hero-value {
    font-size: 3.5rem !important;
  }
  .hero-content {
    margin-bottom: 20px !important;
  }

  /* Возвращаем нормальный вид карточке 4 статов */
  .card-general-stats {
    min-height: 240px !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  /* Таблица */
  .table-responsive-wrapper {
    margin: 0;
    width: 100%;
    border-radius: 8px;
  }
  #statsTable th,
  #statsTable td {
    padding: 10px 5px;
    font-size: 0.75rem;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }
  .steps-row {
    flex-direction: column;
    gap: 30px;
  }
}

/* --- КНОПКА С ПРОГРЕССОМ --- */
.btn-progress {
  position: relative;
  overflow: hidden; /* Чтобы бар не вылезал */
  pointer-events: none; /* Блокируем повторные клики */
  color: white !important; /* Текст всегда белый */
  border-color: transparent !important;
}

/* Сам прогресс-бар (фон) */
.btn-progress::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--progress, 0%); /* Управляется через JS переменную */
  background: var(--primary-gradient);
  z-index: 0;
  transition: width 0.2s ease;
  opacity: 0.5; /* Полупрозрачный, чтобы текст читался */
}

/* Текст кнопки поднимаем наверх */
.btn-progress span,
.btn-progress i {
  position: relative;
  z-index: 1;
}
