:root {
  --bg: var(--tg-theme-bg-color, #0f0f14);
  --bg2: var(--tg-theme-secondary-bg-color, #17171f);
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: var(--tg-theme-hint-color, #8b8b96);
  --accent: #8b5cf6;
  --accent2: #6366f1;
  --green: #1db954;
  --yellow: #ffcc00;
  --red: #ef4444;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

#app { max-width: 560px; margin: 0 auto; min-height: 100%; }

.screen { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }

/* ---------- экран подключения ---------- */

.hero { text-align: center; padding: 32px 0 24px; }
.hero-logo {
  width: 84px; height: 84px; margin: 0 auto 16px; font-size: 42px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 26px;
  box-shadow: 0 12px 32px rgba(139, 92, 246, .35);
}
.hero h1 { font-size: 28px; letter-spacing: -.5px; }
.hero p { color: var(--hint); margin-top: 8px; font-size: 15px; max-width: 280px; margin-inline: auto; }

.card {
  background: var(--bg2);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.service-card { display: flex; align-items: center; gap: 12px; }
.service-icon {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #0d0d0d;
}
.service-icon svg { width: 26px; height: 26px; display: block; }
.service-info { flex: 1; min-width: 0; }
.service-name { font-weight: 600; font-size: 16px; }
.service-status { color: var(--hint); font-size: 13px; margin-top: 2px; }
.service-status.ok { color: var(--green); }

.auth-panel { text-align: center; padding: 20px 16px; }
.auth-panel p { color: var(--hint); font-size: 14px; }
.auth-code {
  font-size: 34px; font-weight: 800; letter-spacing: 6px;
  margin: 14px 0; font-variant-numeric: tabular-nums; user-select: all;
}
.waiting { color: var(--hint); font-size: 13px; margin-top: 14px; display: flex; gap: 8px; justify-content: center; align-items: center; }

/* ---------- кнопки ---------- */

.btn {
  border: none; border-radius: 12px; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 12px 18px; color: var(--text);
  background: rgba(255, 255, 255, .08);
  transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-small { padding: 9px 14px; font-size: 14px; flex-shrink: 0; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 8px 24px rgba(139, 92, 246, .3);
}
.btn-yandex { background: var(--yellow); color: #000; width: 100%; }
.btn-cta { width: 100%; padding: 16px; font-size: 16px; margin-top: 8px; }
.btn.connected { background: transparent; color: var(--hint); font-weight: 400; font-size: 13px; }

/* ---------- шапка и вкладки ---------- */

.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 0 16px; }
.topbar h2 { font-size: 20px; }
.btn-back {
  background: var(--bg2); border: none; color: var(--text);
  width: 34px; height: 34px; border-radius: 10px; font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding-bottom: 3px;
}

.tabs {
  display: flex; gap: 6px; background: var(--bg2);
  padding: 4px; border-radius: 12px; margin-bottom: 14px;
}
.tab {
  flex: 1; border: none; background: transparent; color: var(--hint);
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 0; border-radius: 9px; cursor: pointer;
}
.tab.active { background: rgba(255, 255, 255, .1); color: var(--text); }

/* ---------- списки ---------- */

.loading { text-align: center; padding: 60px 0; color: var(--hint); }
.loading p { margin-top: 16px; font-size: 14px; }

.list-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.check-all { display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; cursor: pointer; }
#liked-search {
  flex: 1; min-width: 0; background: var(--bg2); border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px; padding: 9px 12px; color: var(--text); font-family: inherit; font-size: 14px;
  outline: none;
}

.track-list, .item-list { display: flex; flex-direction: column; gap: 4px; }

.row {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 12px; cursor: pointer;
}
.row:active { background: rgba(255, 255, 255, .05); }
.row.checked { background: rgba(139, 92, 246, .12); }

.row-cover {
  width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0;
  background: var(--bg2); object-fit: cover;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.row-info { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

input[type="checkbox"] {
  appearance: none; width: 21px; height: 21px; flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, .25); border-radius: 7px;
  cursor: pointer; position: relative; background: transparent;
}
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after {
  content: "✓"; color: #fff; font-size: 13px; font-weight: 800;
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}

/* ---------- нижняя панель ---------- */

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 12px;
  max-width: 560px; margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, .06);
}
.selection-summary { flex: 1; font-size: 13px; color: var(--hint); line-height: 1.35; }
.selection-summary b { color: var(--text); }

/* ---------- перенос ---------- */

.transfer-center {
  min-height: 70vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 18px;
}
.transfer-center h2 { font-size: 18px; font-weight: 600; max-width: 300px; }
.transfer-counts { color: var(--hint); font-size: 14px; }

.progress-ring { position: relative; width: 150px; height: 150px; }
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg, .ring-fg { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring-bg { stroke: rgba(255, 255, 255, .08); }
.ring-fg {
  stroke: url(#grad), var(--accent); stroke: var(--accent);
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .6s ease;
}
.progress-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums;
}

/* ---------- отчёт ---------- */

.report-header { text-align: center; padding: 36px 0 20px; }
.report-emoji { font-size: 60px; margin-bottom: 10px; }
.report-header h2 { font-size: 24px; }

.report-stats { display: flex; gap: 10px; margin-bottom: 16px; }
.stat {
  flex: 1; background: var(--bg2); border-radius: var(--radius);
  padding: 14px; text-align: center; border: 1px solid rgba(255, 255, 255, .06);
}
.stat-num { font-size: 26px; font-weight: 800; }
.stat-num.ok { color: var(--green); }
.stat-num.bad { color: var(--red); }
.stat-label { font-size: 12px; color: var(--hint); margin-top: 4px; }

.report-section-title { font-size: 14px; font-weight: 600; color: var(--hint); margin: 18px 0 8px; }
.report-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; font-size: 14px; }
.report-item a { color: var(--green); text-decoration: none; font-weight: 600; }
.unmatched-row { padding: 7px 4px; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,.05); }
.unmatched-row .row-sub { margin-top: 1px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block;
  border: 2px solid rgba(255, 255, 255, .15); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.spinner.big { width: 34px; height: 34px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
