/* vidloader — тёмная тема, современный минимализм */

:root {
  --bg: #08090d;
  --card: rgba(21, 24, 33, 0.72);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-strong: rgba(255, 255, 255, 0.14);
  --text: #eef0f6;
  --muted: #8d93a6;
  --accent: #8b7cff;
  --accent-2: #43d9ff;
  --ok: #37e0a0;
  --err: #ff6b6b;
  --radius: 18px;
  --radius-sm: 12px;
}

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

/* Атрибут hidden должен побеждать любые display из классов (.card, .result-card
   и т.п. задают display: grid/flex и иначе оставляют пустые блоки видимыми). */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* Колонка на всю высоту экрана: каркас растягивается, подвал прижимается
     к самому низу страницы даже на коротком контенте. */
  display: flex;
  flex-direction: column;
}

/* Мягкое цветное свечение на фоне */
.glow {
  position: fixed;
  inset: -30% -10% auto;
  height: 70vh;
  background:
    radial-gradient(45% 55% at 22% 0%, rgba(139, 124, 255, 0.20), transparent 70%),
    radial-gradient(40% 50% at 82% 8%, rgba(67, 217, 255, 0.13), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Шапка ---------- */

.topbar {
  position: relative;
  z-index: 2;
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.2px;
}
.brand svg { width: 26px; height: 26px; }

.badge {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

/* ---------- Каркас ---------- */

.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  /* Занимаем всё свободное место, чтобы подвал уехал вниз. */
  flex: 1 0 auto;
}

/* ---------- Hero ---------- */

.hero {
  padding: 38px 0 6px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(30px, 6vw, 46px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -1.2px;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  color: var(--muted);
  font-size: 14.5px;
  margin-top: 14px;
  max-width: 46ch;
  margin-inline: auto;
}

/* ---------- Карточки ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  animation: rise 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
}

/* ---------- Поле ввода ---------- */

.search-card form {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.field {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.field-icon {
  position: absolute;
  left: 14px;
  width: 19px;
  height: 19px;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.2s;
}

.field:focus-within .field-icon { color: var(--accent); }

input[type="text"] {
  width: 100%;
  padding: 14px 76px 14px 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke-strong);
  background: rgba(8, 9, 13, 0.75);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  text-overflow: ellipsis;
}
input[type="text"]::placeholder { color: var(--muted); }
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 124, 255, 0.18);
}
input[type="text"]:disabled { opacity: 0.6; cursor: wait; }

.clear-btn {
  position: absolute;
  right: 12px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.clear-btn svg { width: 13px; height: 13px; }
.clear-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }

/* Вторая кнопка в поле (вставить) стоит левее «очистить» */
#pasteBtn { right: 44px; }

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

.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(100deg, var(--accent), #6f5cf0);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 6px 22px rgba(139, 124, 255, 0.32);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 8px 28px rgba(139, 124, 255, 0.42);
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.65; cursor: default; }

.btn-primary.wide { width: 100%; margin-top: 16px; padding: 15px; font-size: 15.5px; }
.btn-primary.wide svg { width: 19px; height: 19px; }

.btn-ghost {
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--stroke-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.22); }
.btn-ghost:disabled { opacity: 0.6; cursor: default; }
.btn-ghost.danger { color: #ff9d9d; }
.btn-ghost.danger:hover { background: rgba(255, 107, 107, 0.1); border-color: rgba(255, 107, 107, 0.35); }

.spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-primary.loading .spinner { display: block; }
.btn-primary.loading .btn-label,
.btn-primary.loading #downloadLabel { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-2);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.15s;
}
.link-btn:hover { opacity: 1; text-decoration: underline; }

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

/* ---------- Подсказки / панель cookies ---------- */

.under-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.panel {
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: rgba(8, 9, 13, 0.6);
  border: 1px solid var(--stroke);
  animation: rise 0.25s ease both;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.panel-note { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.panel-note.small { font-size: 11.5px; }

.panel textarea {
  width: 100%;
  margin-top: 10px;
  padding: 11px;
  border-radius: 10px;
  border: 1px solid var(--stroke-strong);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
  outline: none;
}
.panel textarea:focus { border-color: var(--accent); }

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.panel-actions .panel-note { flex: 1; min-width: 180px; margin: 0; }

/* ---------- Ошибка ---------- */

.alert {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 107, 107, 0.09);
  border: 1px solid rgba(255, 107, 107, 0.32);
  color: #ffb3b3;
  font-size: 13.5px;
  line-height: 1.45;
  animation: rise 0.2s ease both;
}

/* ---------- Скелетон загрузки ---------- */

.skeleton-card { display: grid; grid-template-columns: 180px 1fr; gap: 18px; }

.sk-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
}

.sk-line {
  height: 13px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  margin-bottom: 10px;
}
.sk-line.w80 { width: 80%; }
.sk-line.w40 { width: 40%; margin-bottom: 18px; }

.sk-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.sk-chips span {
  width: 74px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.sk-thumb, .sk-line, .sk-chips span {
  position: relative;
  overflow: hidden;
}
.sk-thumb::after, .sk-line::after, .sk-chips span::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Результат ---------- */

.result-card {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px;
  align-items: start;
}

.thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--stroke);
}
.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.duration[hidden] { display: none; }

.result-body { min-width: 0; }

.result-body h2 {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

/* ---------- Форматы ---------- */

.formats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.fmt {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.fmt:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--stroke-strong); }
.fmt:active { transform: scale(0.98); }

.fmt-q { font-size: 13.5px; font-weight: 650; line-height: 1.15; white-space: nowrap; }
.fmt-s { font-size: 10.5px; color: var(--muted); line-height: 1.2; }

.fmt.active {
  border-color: var(--accent);
  background: rgba(139, 124, 255, 0.14);
  box-shadow: 0 0 0 1px rgba(139, 124, 255, 0.35) inset;
}
.fmt.active .fmt-q { color: #c7bdff; }
.fmt.active .fmt-s { color: #a79af0; }

/* ---------- Шкала «Сейчас начнётся загрузка» под кнопкой ---------- */

.loading-note {
  margin-top: 12px;
  animation: rise 0.25s ease both;
}

.loading-text {
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.1px;
  margin-bottom: 8px;
}

.loading-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

#loadingFill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  /* Плавное движение вместо скачков каждые 250 мс */
  transition: width 0.3s ease-out;
  box-shadow: 0 0 10px rgba(139, 124, 255, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  #loadingFill { transition: width 0.1s linear; }
}

/* ---------- Подвал ---------- */

/* Подвал — последний элемент .wrap (flex-колонка): margin-top: auto прижимает
   его к нижнему краю экрана, когда контента мало. */
footer {
  margin-top: auto;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  padding: 22px 2px 2px;
  opacity: 0.7;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ---------- Адаптив ---------- */

@media (max-width: 620px) {
  .wrap, .topbar { padding-left: 16px; padding-right: 16px; }

  .search-card form { flex-direction: column; }
  .search-card .btn-primary { width: 100%; }

  .result-card,
  .skeleton-card {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .thumb-wrap { max-width: 100%; }

  .hero { padding-top: 28px; }
  .under-row { flex-direction: column; align-items: flex-start; gap: 6px; }
}

@media (max-width: 400px) {
  .card { padding: 16px; }
  .fmt { padding: 7px 10px; }
  .fmt-q { font-size: 12.5px; }
}

/* ---------- Модальные окна (согласие, «не робот») ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 5, 9, 0.78);
  backdrop-filter: blur(7px);
  animation: fadeIn 0.2s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 440px;
  padding: 26px 26px 22px;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.13));
  border-radius: 18px;
  background: linear-gradient(180deg, #14172a, #0d0f18);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.62);
  animation: modalIn 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h2 {
  font-size: 18px;
  letter-spacing: -0.3px;
  margin-bottom: 11px;
}

.modal-text {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.58;
  margin-bottom: 10px;
}

.modal-text.small { font-size: 12px; }
.modal-text a { color: var(--accent-2); text-decoration: none; }
.modal-text a:hover { text-decoration: underline; }

.modal-details {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.modal-details p { margin: 0 0 6px; }
.modal-details p:last-child { margin-bottom: 0; }
.modal-details ul { margin: 4px 0 8px; padding-left: 18px; }
.modal-details code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(139, 124, 255, 0.15);
  color: #c7bdff;
  font-size: 11.5px;
}

.modal-actions {
  display: flex;
  gap: 9px;
  margin-top: 18px;
}
.modal-actions .btn-primary { flex: 1; margin: 0; }

.btn-ghost {
  padding: 13px 18px;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.14));
  border-radius: 11px;
  background: transparent;
  color: var(--text, #eceaf6);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }

.captcha-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 15px;
  border-radius: 13px;
  background: rgba(139, 124, 255, 0.13);
  border: 1px solid rgba(139, 124, 255, 0.28);
  color: var(--accent, #8b7cff);
}
.captcha-icon svg { width: 24px; height: 24px; }

/* Пока окно согласия открыто, страница не прокручивается */
body.locked { overflow: hidden; }

@media (max-width: 480px) {
  .modal { padding: 22px 18px 18px; border-radius: 16px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn-ghost { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay, .modal { animation: none !important; }
}

/* ---------- Кнопка «Cookie» в шапке ---------- */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 9px;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.13));
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text, #eceaf6);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}
.icon-btn:hover {
  background: rgba(139, 124, 255, 0.11);
  border-color: rgba(139, 124, 255, 0.36);
}
.icon-btn svg { width: 15px; height: 15px; opacity: 0.9; }

/* Точка-индикатор: cookie заданы */
.icon-btn .dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3ddc97;
  box-shadow: 0 0 0 2px var(--bg, #08090d), 0 0 8px rgba(61, 220, 151, 0.75);
}

/* ---------- Окно ввода cookie ---------- */

#cookiesInput {
  width: 100%;
  margin-top: 14px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.14));
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text, #eceaf6);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 108px;
  outline: none;
  transition: border-color 0.16s;
}
#cookiesInput::placeholder { color: #5c6076; font-family: inherit; }
#cookiesInput:focus { border-color: rgba(139, 124, 255, 0.55); }

.cookies-status {
  margin-top: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted, #8b8fa6);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
}
.cookies-status.good {
  background: rgba(61, 220, 151, 0.11);
  border-color: rgba(61, 220, 151, 0.3);
  color: #7ceab5;
}
.cookies-status.bad {
  background: rgba(255, 107, 129, 0.11);
  border-color: rgba(255, 107, 129, 0.32);
  color: #ff9bab;
}

/* Инструкция «как получить cookie» */
.how {
  margin-top: 14px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}
.how summary {
  padding: 10px 14px;
  cursor: pointer;
  color: var(--accent-2, #43d9ff);
  font-size: 12.5px;
  list-style: none;
  user-select: none;
}
.how summary::-webkit-details-marker { display: none; }
.how summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.18s;
}
.how[open] summary::before { content: "▾ "; }
.how ol {
  margin: 0;
  padding: 0 14px 10px 30px;
  color: var(--muted, #8b8fa6);
  font-size: 12px;
  line-height: 1.65;
}
.how ol li { margin-bottom: 3px; }
.how ol strong { color: var(--text, #eceaf6); font-weight: 600; }
.how-note {
  margin: 0;
  padding: 0 14px 12px;
  color: var(--muted, #8b8fa6);
  font-size: 11.5px;
  line-height: 1.55;
}
.how-note code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(139, 124, 255, 0.15);
  color: #c7bdff;
  font-size: 11px;
}

.link-close {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 6px;
  border: 0;
  background: transparent;
  color: var(--muted, #8b8fa6);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.16s;
}
.link-close:hover { color: var(--text, #eceaf6); }

.modal-text.small strong { color: var(--text, #eceaf6); font-weight: 600; }

@media (max-width: 560px) {
  .topbar-right .badge { display: none; }
  .icon-btn span { display: none; }
  .icon-btn { padding: 8px; }
}
