:root {
  --tw-bg: radial-gradient(
    circle at top,
    #161c2d 0%,
    #05070f 60%,
    #020205 100%
  );
  --tw-card-bg: rgba(11, 16, 31, 0.82);
  --tw-card-border: rgba(255, 255, 255, 0.08);
  --tw-text: #e8eefc;
  --tw-subtext: rgba(232, 238, 252, 0.7);
  --tw-primary: #1d9bf0;
  --tw-primary-dark: #1174bd;
  --tw-success: #3fbf8c;
  --tw-warning: #f5a623;
  --tw-font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --tw-shadow-soft: 0 24px 40px rgba(5, 11, 26, 0.45);
  --tw-radius-lg: 24px;
  --tw-radius-md: 16px;
  --tw-radius-sm: 10px;
  color-scheme: dark;
}

[hidden] {
  display: none !important;
}

span.tw-video__indicator {
  cursor: pointer;
}
div#statusMessage {
  margin-top: 10px;
}
* {
  box-sizing: border-box;
}

body.tw-body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--tw-font);
  color: var(--tw-text);
  background: #03060f;
  position: relative;
  overflow-x: hidden;
}

.tw-gradient {
  position: absolute;
  inset: 0;
  background: var(--tw-bg);
  opacity: 0.9;
  z-index: -2;
}

.tw-main {
  position: relative;
  max-width: min(1100px, 90vw);
  margin: 0 auto;
  padding: clamp(3rem, 10vw, 6rem) 0 8rem;
  display: flex;
  flex-direction: column;
  gap: clamp(2.5rem, 5vw, 4rem);
}

.tw-card {
  background: var(--tw-card-bg);
  border: 1px solid var(--tw-card-border);
  border-radius: var(--tw-radius-lg);
  padding: clamp(2.5rem, 5vw, 3.5rem);
  box-shadow: var(--tw-shadow-soft);
  backdrop-filter: blur(18px);
  position: relative;
  isolation: isolate;
}

.tw-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    135deg,
    rgba(29, 155, 240, 0.4),
    rgba(15, 208, 177, 0.25)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.7;
  pointer-events: none;
}

.tw-card__header h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin: 0.4rem 0 0.8rem;
  letter-spacing: -0.02em;
}

.tw-card__header p {
  margin: 0;
  color: var(--tw-subtext);
  font-size: 1rem;
  line-height: 1.6;
}

.tw-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(63, 191, 140, 0.18);
  border: 1px solid rgba(63, 191, 140, 0.35);
  color: var(--tw-success);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

.tw-form {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.tw-input {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.75rem;
  background: rgba(12, 18, 35, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--tw-radius-md);
  padding: 1rem 1.2rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tw-input:focus-within {
  border-color: rgba(29, 155, 240, 0.8);
  box-shadow: 0 0 0 8px rgba(29, 155, 240, 0.12);
}

.tw-input__icon svg {
  width: 1.5rem;
  height: 1.5rem;
  color: rgba(232, 238, 252, 0.9);
}

.tw-input input {
  background: transparent;
  border: 0;
  outline: none;
  color: inherit;
  font-size: 1.05rem;
  width: 100%;
  caret-color: var(--tw-primary);
}

.tw-input input::placeholder {
  color: rgba(232, 238, 252, 0.35);
}

.tw-help {
  margin: 0;
  color: rgba(232, 238, 252, 0.55);
  font-size: 0.9rem;
}

.tw-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, var(--tw-primary), #1d80f0);
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.8rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 24px rgba(19, 128, 214, 0.35);
}

.tw-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(19, 128, 214, 0.45);
}

.tw-button:active {
  transform: translateY(0);
}

.tw-button__icon svg {
  width: 1.2rem;
  height: 1.2rem;
}

.tw-status {
  min-height: 1.25rem;
  font-size: 0.95rem;
  color: var(--tw-warning);
  font-weight: 500;
}

.tw-status--success {
  color: var(--tw-success);
}

.tw-status--error {
  color: #ff7d7d;
}

.tw-status--info {
  color: rgba(232, 238, 252, 0.75);
}

.tw-loading {
  display: none;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: rgba(232, 238, 252, 0.8);
}

.tw-loading.is-visible {
  display: flex;
}

.tw-loading__spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--tw-primary);
  border-radius: 50%;
  animation: tw-spin 0.9s linear infinite;
}

@keyframes tw-spin {
  to {
    transform: rotate(360deg);
  }
}

.tw-results {
  background: rgba(8, 12, 24, 0.78);
  border-radius: var(--tw-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: clamp(2rem, 4vw, 3rem);
  box-shadow: var(--tw-shadow-soft);
  backdrop-filter: blur(16px);
}

.tw-results__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.tw-results__header h2 {
  margin: 0;
  font-size: 1.6rem;
}

.tw-results__header p {
  margin: 0.2rem 0 0;
  color: var(--tw-subtext);
}

.tw-chip {
  background: rgba(29, 155, 240, 0.12);
  color: var(--tw-primary);
  border: 1px solid rgba(29, 155, 240, 0.35);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.tw-chip:hover {
  background: rgba(29, 155, 240, 0.2);
}

.tw-grid {
  display: grid;
  gap: 1.6rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.tw-video {
  position: relative;
  background: rgba(10, 15, 28, 0.88);
  border-radius: var(--tw-radius-md);
  border: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.tw-video--selected {
  border-color: rgba(63, 191, 140, 0.55);
  box-shadow: 0 18px 36px rgba(32, 115, 84, 0.45);
}

.tw-video:hover {
  transform: translateY(-4px);
  border-color: rgba(29, 155, 240, 0.45);
  box-shadow: 0 18px 36px rgba(13, 30, 64, 0.6);
}

.tw-video__select {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
}

.tw-video__checkbox {
  appearance: none;
  position: absolute;
  inset: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.tw-video__indicator {
  width: 2rem;
  height: 2rem;
  border-radius: 12px;
  background: rgba(3, 8, 18, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}

.tw-video__indicator::after {
  content: "";
  width: 1rem;
  height: 1rem;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--tw-primary), #1da1f2);
  transform: scale(0);
  transition: transform 0.2s ease;
}

.tw-video__checkbox:checked + .tw-video__indicator {
  border-color: rgba(29, 155, 240, 0.8);
  background: rgba(29, 155, 240, 0.2);
  box-shadow: 0 8px 18px rgba(29, 155, 240, 0.35);
}

.tw-video__checkbox:checked + .tw-video__indicator::after {
  transform: scale(1);
}

.tw-video__preview {
  position: relative;
  padding-top: 56.25%;
  overflow: hidden;
}

.tw-video__preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.tw-video:hover .tw-video__preview img {
  transform: scale(1.05);
}

.tw-video__badge {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  background: rgba(3, 8, 18, 0.85);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: rgba(232, 238, 252, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tw-video__badge::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--tw-success);
}

.tw-video__meta {
  padding: 1.1rem 1.3rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tw-video__meta h3 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.4;
  max-height: 3.08rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tw-video__details {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(232, 238, 252, 0.7);
  line-height: 1.5;
}

.tw-video__link {
  margin-top: auto;
  font-size: 0.88rem;
  color: rgba(29, 155, 240, 0.9);
  text-decoration: none;
  font-weight: 600;
}

.tw-video__link:hover {
  text-decoration: underline;
}

.tw-download {
  position: fixed;
  bottom: clamp(1.5rem, 4vw, 2.5rem);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  background: linear-gradient(135deg, var(--tw-primary), #1d80f0);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 1rem 2.4rem;
  font-size: 1.05rem;
  font-weight: 600;
  box-shadow: 0 20px 40px rgba(14, 113, 194, 0.35);
  cursor: pointer;
  z-index: 20;
  transition: transform 0.2s ease;
}

.tw-download:hover {
  transform: translate(-50%, -2px);
}

.tw-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 18, 0.68);
  backdrop-filter: blur(6px);
  z-index: 30;
  display: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  place-items: center;
  padding: 2rem;
}

.tw-overlay.is-visible {
  display: grid;
  opacity: 1;
  pointer-events: auto;
}

.tw-overlay__content {
  background: rgba(6, 10, 20, 0.92);
  border-radius: var(--tw-radius-md);
  border: 1px solid rgba(29, 155, 240, 0.25);
  padding: 2.2rem 2.8rem;
  text-align: center;
  display: grid;
  gap: 1.1rem;
  color: rgba(232, 238, 252, 0.9);
  max-width: 320px;
}

.tw-overlay__content small {
  color: rgba(232, 238, 252, 0.6);
}

@media (max-width: 720px) {
  .tw-main {
    padding-inline: 1.2rem;
  }

  .tw-card,
  .tw-results {
    padding: 2rem;
  }

  .tw-download {
    width: calc(100% - 2.4rem);
    justify-content: center;
  }
}

@media (max-width: 500px) {
  .tw-card__header h1 {
    font-size: 1.9rem;
  }

  .tw-input {
    grid-template-columns: 1.5rem 1fr;
    padding: 0.85rem 1rem;
  }

  .tw-input__icon svg {
    width: 1.2rem;
    height: 1.2rem;
  }

  .tw-button {
    width: 100%;
  }
}

.tw-help--muted {
  color: rgba(232, 238, 252, 0.5);
  margin-top: -0.3rem;
}

.tw-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: rgba(12, 18, 35, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--tw-radius-md);
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tw-toggle:hover {
  border-color: rgba(29, 155, 240, 0.4);
  box-shadow: 0 8px 20px rgba(19, 128, 214, 0.25);
}

.tw-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.tw-toggle__control {
  width: 2.6rem;
  height: 1.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  position: relative;
  transition: background 0.2s ease;
}

.tw-toggle__control::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.25rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: #0a1022;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transform: translateY(-50%);
  transition: transform 0.2s ease, background 0.2s ease;
}

.tw-toggle input:focus-visible + .tw-toggle__control {
  box-shadow: 0 0 0 3px rgba(29, 155, 240, 0.4);
}

.tw-toggle input:checked + .tw-toggle__control {
  background: linear-gradient(135deg, var(--tw-primary), #1d80f0);
}

.tw-toggle input:checked + .tw-toggle__control::after {
  transform: translate(1.1rem, -50%);
  background: #fff;
}

.tw-toggle__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.95rem;
  color: var(--tw-text);
}

.tw-toggle__text small {
  font-size: 0.78rem;
  color: rgba(232, 238, 252, 0.6);
}
