:root {
  --bg-page: #0b0d13;
  --bg-card: #131722;
  --bg-card-hover: #161b28;
  --bg-subtle: #0f131c;
  --bg-inset: #090b10;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --border-focus: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-glow: rgba(37, 99, 235, 0.25);
  --green: #10b981;
  --green-subtle: rgba(16, 185, 129, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ============================================================
   Header & Platform Switcher (Ultra-Clean Modern Segment)
   ============================================================ */
.header {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 13, 19, 0.95);
  backdrop-filter: blur(16px);
  padding: 0.65rem 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #fff;
}

.brand-icon {
  width: 28px;
  height: 28px;
  background: #1d9bf0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #fff;
  font-weight: 800;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.platform-switcher {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.platform-btn {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 999px;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.platform-btn:hover {
  color: #fff;
}

.platform-btn.active-x,
.platform-btn.active-threads,
.platform-btn.active-tiktok {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.header-nav-links {
  display: flex;
  gap: 0.9rem;
}

.header-nav-links a {
  color: var(--text-subtle);
  font-size: 0.82rem;
  text-decoration: none;
  transition: color 0.15s;
}

.header-nav-links a:hover {
  color: var(--text-main);
}

/* ============================================================
   Main Hero Area
   ============================================================ */
.main {
  padding: 2.8rem 0 3.5rem;
  flex: 1;
}

.title-area {
  text-align: center;
  margin-bottom: 2rem;
}

.title-area h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  line-height: 1.25;
  margin-bottom: 0.65rem;
}

.title-area p {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 540px;
  margin: 0 auto;
}

/* ============================================================
   Downloader Input Box
   ============================================================ */
.input-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  position: relative;
}

.input-form {
  display: flex;
  gap: 0.6rem;
}

.input-box-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.url-input {
  width: 100%;
  height: 50px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 4.5rem 0 1.1rem;
  font-size: 16px; /* 锁死 16px 杜绝 iOS Safari 强制缩放 */
  color: var(--text-main);
  outline: none;
  transition: all 0.15s ease;
}

.url-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.url-input::placeholder {
  color: var(--text-subtle);
  font-size: 0.9rem;
}

.btn-paste {
  position: absolute;
  right: 8px;
  height: 34px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-paste:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-submit {
  height: 50px;
  padding: 0 1.8rem;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  white-space: nowrap;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-submit:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.btn-submit:active {
  transform: translateY(0);
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.quick-hints {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-subtle);
  flex-wrap: wrap;
}

.quick-hints span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* ============================================================
   Loading & Status
   ============================================================ */
.status-box {
  margin-top: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: none;
  text-align: center;
}

.loading-bar {
  height: 3px;
  width: 100%;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.8rem;
}

.loading-line {
  height: 100%;
  width: 40%;
  background: var(--primary);
  border-radius: 999px;
  animation: moveBar 1.2s infinite ease-in-out;
}

@keyframes moveBar {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(100%); width: 60%; }
  100% { transform: translateX(250%); }
}

/* ============================================================
   Result Card & Segmented Control Tabs
   ============================================================ */
.result-box {
  margin-top: 1.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: none;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

.tweet-info {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.85rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.015);
}

.tweet-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-inset);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.tweet-meta {
  overflow: hidden;
}

.tweet-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

.tweet-handle {
  font-size: 0.8rem;
  color: var(--text-subtle);
}

.tweet-content {
  padding: 1.1rem 1.25rem;
  font-size: 0.92rem;
  color: var(--text-main);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  line-height: 1.55;
  word-break: break-word;
}

/* Segmented Control Pill Tabs */
.format-selector {
  display: flex;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin: 1.1rem 1.25rem 0.5rem;
}

.format-tab {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.format-tab:hover:not(.active) {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.format-tab.active {
  color: #fff;
  background: var(--primary);
  font-weight: 600;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Download Options List */
.downloads-list {
  padding: 0.8rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  gap: 0.8rem;
  transition: all 0.15s ease;
}

.download-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.item-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.item-title {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag-badge {
  font-size: 0.72rem;
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 0.15rem 0.5rem;
  border-radius: 5px;
  font-weight: 600;
}

.tag-hd {
  font-size: 0.7rem;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 700;
}

.item-desc {
  font-size: 0.78rem;
  color: var(--text-subtle);
}

.btn-action {
  height: 38px;
  padding: 0 1.2rem;
  background: var(--primary);
  border: none;
  border-radius: 7px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-action:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-action:active {
  transform: translateY(0);
}

.btn-action.audio-btn {
  background: #059669;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

.btn-action.audio-btn:hover {
  background: #047857;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

/* ============================================================
   GIF Meme Maker & Frame Studio (Phase 2 Component)
   ============================================================ */
.tool-panel {
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tool-panel-header {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.tool-panel-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tool-panel-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.preview-video-container {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.preview-video {
  width: 100%;
  max-height: 240px;
  background: #000;
  display: block;
  object-fit: contain;
}

.timeline-controller {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timeline-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.timeline-label {
  color: var(--text-muted);
}

.timeline-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: 5px;
}

.range-slider {
  width: 100%;
  height: 6px;
  background: var(--bg-inset);
  border-radius: 999px;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s ease;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.tool-actions {
  display: flex;
  gap: 0.6rem;
}

.btn-tool {
  flex: 1;
  height: 38px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-tool:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-gif {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-gif:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-frame {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border-color: rgba(255, 255, 255, 0.08);
}

.btn-frame:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.gif-result-box {
  margin-top: 0.5rem;
  padding: 1.1rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
  display: none;
}

.gif-preview-img {
  max-width: 100%;
  max-height: 220px;
  border-radius: var(--radius-sm);
  margin-bottom: 0.85rem;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   Bookmarklet & Shortcut Strip (Phase 3 Component)
   ============================================================ */
.shortcut-strip {
  margin-top: 1.25rem;
  padding: 0.9rem 1.15rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  transition: border-color 0.15s ease;
}

.shortcut-strip:hover {
  border-color: var(--border-hover);
}

.shortcut-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 240px;
}

.shortcut-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.shortcut-desc {
  font-size: 0.78rem;
  color: var(--text-subtle);
  line-height: 1.4;
}

.shortcut-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-bookmarklet {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(37, 99, 235, 0.12);
  color: #60a5fa;
  border: 1px dashed rgba(59, 130, 246, 0.4);
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  cursor: grab;
  user-select: none;
  transition: all 0.15s ease;
}

.btn-bookmarklet:hover {
  background: rgba(37, 99, 235, 0.22);
  border-color: #3b82f6;
  color: #fff;
}

.btn-bookmarklet:active {
  cursor: grabbing;
}

.btn-copy-code {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy-code:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.btn-pwa-install {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.28rem 0.65rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-pwa-install:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* ============================================================
   Simple How-To Guide
   ============================================================ */
.simple-guide {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding-top: 2.5rem;
}

.simple-guide h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-align: center;
  color: var(--text-main);
}

.steps-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.step-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: border-color 0.15s;
}

.step-item:hover {
  border-color: var(--border-hover);
}

.step-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.4rem;
  letter-spacing: 0.05em;
}

.step-item h3 {
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #fff;
}

.step-item p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  background: var(--bg-page);
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-subtle);
  flex-wrap: wrap;
  gap: 0.8rem;
}

.footer-nav {
  display: flex;
  gap: 1.2rem;
}

.footer-nav a {
  color: var(--text-subtle);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-nav a:hover {
  color: var(--text-muted);
}

/* ============================================================
   Modal (Countdown Waiting)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.1rem;
}

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

.modal-box h3 {
  font-size: 1.15rem;
  margin-bottom: 0.4rem;
  color: #fff;
}

.modal-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================================
   Mobile Queries (< 640px)
   ============================================================ */
@media (max-width: 640px) {
  .container {
    padding: 0 0.9rem;
  }

  .main {
    padding: 1.8rem 0 2.5rem;
  }

  .title-area h1 {
    font-size: 1.55rem;
    padding: 0 0.25rem;
  }

  .title-area p {
    font-size: 0.88rem;
  }

  .input-card {
    padding: 1rem;
  }

  .input-form {
    flex-direction: column;
    gap: 0.6rem;
  }

  .url-input {
    height: 48px;
    padding: 0 4.2rem 0 0.95rem;
  }

  .btn-submit {
    height: 48px;
    width: 100%;
    font-size: 0.98rem;
  }

  .quick-hints {
    gap: 0.85rem;
    font-size: 0.78rem;
  }

  .format-selector {
    margin: 1rem 0.85rem 0.5rem;
    gap: 2px;
    padding: 3px;
  }

  .format-tab {
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
  }

  .downloads-list {
    padding: 0.65rem 0.85rem 1rem;
  }

  .download-item {
    padding: 0.75rem 0.9rem;
  }

  .item-title {
    font-size: 0.85rem;
  }

  .btn-action {
    height: 36px;
    padding: 0 0.95rem;
    font-size: 0.82rem;
  }

  .tool-actions {
    flex-direction: column;
  }

  .btn-tool {
    width: 100%;
  }

  .steps-list {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .step-item {
    padding: 1rem;
  }

  .footer-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
  }
}
