:root {
  color-scheme: light;
  --blue: #1479e8;
  --blue-dark: #075ebd;
  --ink: #142033;
  --muted: #6b7788;
  --line: #dfe7f0;
  --surface: rgba(255, 255, 255, 0.92);
  --background: #f6f9fc;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 24px 70px rgba(31, 58, 95, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 0%, rgba(20, 121, 232, 0.12), transparent 28rem),
    radial-gradient(circle at 90% 22%, rgba(67, 191, 255, 0.12), transparent 24rem),
    linear-gradient(180deg, #fbfdff 0%, var(--background) 65%, #f2f6fb 100%);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.site-header {
  width: min(1080px, calc(100% - 40px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 760;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: white;
  border-radius: 11px;
  background: linear-gradient(145deg, #2095fa, #0967d8);
  box-shadow: 0 8px 24px rgba(20, 121, 232, 0.28);
}

.brand-mark svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

main {
  width: min(840px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(48px, 9vh, 102px) 0 54px;
}

.hero {
  text-align: center;
}

.eyebrow {
  width: fit-content;
  margin: 0 auto 22px;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #315b85;
  border: 1px solid rgba(20, 121, 232, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0.02em;
  backdrop-filter: blur(12px);
}

.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #24b36b;
  box-shadow: 0 0 0 4px rgba(36, 179, 107, 0.12);
}

h1 {
  max-width: 760px;
  margin: 0 auto;
  font-size: clamp(42px, 7vw, 68px);
  line-height: 1.08;
  letter-spacing: -0.055em;
}

.hero-copy {
  max-width: 610px;
  margin: 23px auto 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.search-form {
  max-width: 770px;
  margin: 40px auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  text-align: left;
}

.input-shell {
  min-width: 0;
  height: 62px;
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  box-shadow: 0 12px 36px rgba(31, 58, 95, 0.08);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.input-shell:focus-within {
  border-color: rgba(20, 121, 232, 0.72);
  box-shadow:
    0 0 0 4px rgba(20, 121, 232, 0.1),
    0 15px 40px rgba(31, 58, 95, 0.1);
}

.link-icon {
  width: 21px;
  margin-left: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: #8290a3;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.input-shell input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 48px 0 13px;
  color: var(--ink);
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
}

.input-shell input::placeholder {
  color: #96a1b0;
}

.clear-button {
  width: 32px;
  height: 32px;
  margin-right: 12px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #8290a3;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 140ms ease,
    background 140ms ease;
}

.clear-button.visible {
  opacity: 1;
  pointer-events: auto;
}

.clear-button:hover {
  background: #eff3f8;
}

.clear-button svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.download-button {
  min-width: 132px;
  height: 62px;
  padding: 0 24px;
  position: relative;
  color: white;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #1785f4, #0d6ed9);
  box-shadow: 0 14px 30px rgba(20, 121, 232, 0.24);
  font-weight: 740;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.download-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 17px 34px rgba(20, 121, 232, 0.3);
}

.download-button:active {
  transform: translateY(0);
}

.download-button:disabled {
  cursor: wait;
  opacity: 0.78;
  transform: none;
}

.spinner {
  width: 19px;
  height: 19px;
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -9.5px 0 0 -9.5px;
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.download-button.loading .button-label {
  visibility: hidden;
}

.download-button.loading .spinner {
  display: block;
}

.status-region {
  max-width: 770px;
  margin: 15px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.status-region.error {
  padding: 12px 15px;
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.16);
  border-radius: 12px;
  background: var(--danger-soft);
  text-align: left;
}

.result-region {
  margin-top: 34px;
}

.result-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: enter 260ms ease both;
}

.tweet-body {
  padding: 22px;
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr);
  gap: 20px;
}

.tweet-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: cover;
  border-radius: 14px;
  background: #eaf0f7;
}

.tweet-details {
  min-width: 0;
}

.author-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #eaf0f7;
}

.author-name {
  display: block;
  font-size: 14px;
  font-weight: 740;
  line-height: 1.3;
}

.author-handle {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.tweet-text {
  margin: 14px 0 0;
  display: -webkit-box;
  overflow: hidden;
  color: #344054;
  font-size: 14px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.tweet-meta {
  margin-top: 12px;
  color: #7d8999;
  font-size: 12px;
}

.format-panel {
  padding: 0 22px 22px;
}

.format-heading {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.format-heading h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.format-heading span {
  color: var(--muted);
  font-size: 12px;
}

.video-format-list {
  display: grid;
  gap: 9px;
}

.format-row {
  min-height: 58px;
  padding: 10px 12px 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #e7edf4;
  border-radius: 13px;
  background: white;
  transition:
    border-color 150ms ease,
    transform 150ms ease,
    box-shadow 150ms ease;
}

.format-row:hover {
  border-color: rgba(20, 121, 232, 0.3);
  box-shadow: 0 9px 24px rgba(31, 58, 95, 0.08);
  transform: translateY(-1px);
}

.quality-badge {
  min-width: 58px;
  padding: 7px 9px;
  color: var(--blue-dark);
  border-radius: 9px;
  background: #eaf4ff;
  font-size: 12px;
  font-weight: 780;
  text-align: center;
}

.format-info {
  min-width: 0;
  flex: 1;
}

.format-info strong {
  display: block;
  font-size: 13px;
}

.format-info span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.format-link {
  padding: 9px 13px;
  color: white;
  border-radius: 9px;
  background: var(--blue);
  font-size: 12px;
  font-weight: 720;
  text-decoration: none;
  white-space: nowrap;
}

.format-link:hover {
  background: var(--blue-dark);
}

footer {
  width: min(840px, calc(100% - 40px));
  margin: 0 auto;
  padding: 10px 0 36px;
  color: #8792a1;
  text-align: center;
  font-size: 11px;
  line-height: 1.7;
}

footer p {
  margin: 3px 0;
}

.sr-only {
  width: 1px;
  height: 1px;
  padding: 0;
  position: absolute;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 680px) {
  .site-header {
    width: calc(100% - 28px);
    min-height: 68px;
  }

  .header-note {
    display: none;
  }

  main {
    width: calc(100% - 28px);
    padding-top: 48px;
  }

  h1 {
    font-size: clamp(38px, 13vw, 52px);
  }

  .hero-copy {
    margin-top: 18px;
    font-size: 14px;
  }

  .search-form {
    margin-top: 30px;
    grid-template-columns: 1fr;
  }

  .download-button {
    width: 100%;
  }

  .tweet-body {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .tweet-thumb {
    max-height: 230px;
  }

  .format-panel {
    padding: 0 16px 16px;
  }

  .format-row {
    padding-left: 10px;
  }

  .format-info span {
    display: none;
  }

  footer {
    width: calc(100% - 34px);
    padding-bottom: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
