:root {
  --top-bar-safe-height: 92px;
  --bg: #f7faf8;
  --card: #ffffff;
  --panel: rgba(15, 23, 42, 0.04);
  --text: #121723;
  --muted: rgba(18, 23, 35, 0.46);
  --border: rgba(15, 23, 42, 0.08);
  --button: #14b86a;
  --button-text: #ffffff;
  --shadow: 0 18px 44px rgba(31, 46, 91, 0.06);
}

body[data-theme='dark'] {
  --bg: #0d1118;
  --card: #131a24;
  --panel: rgba(255, 255, 255, 0.04);
  --text: #f6f8fc;
  --muted: rgba(246, 248, 252, 0.48);
  --border: rgba(255, 255, 255, 0.08);
  --button: #19c16f;
  --button-text: #ffffff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}

.logo-refresh {
  position: absolute;
  top: 18px;
  left: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-refresh img {
  display: block;
  height: 42px;
  width: auto;
}

.theme-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.help-toggle {
  position: absolute;
  top: 18px;
  right: 130px;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.top-help-nav {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: calc(100vw - 280px);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.top-help-nav::-webkit-scrollbar {
  display: none;
}

.top-help-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.top-help-link:hover {
  border-color: rgba(79, 124, 255, 0.28);
}

.lang-toggle {
  position: absolute;
  top: 18px;
  right: 74px;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.lang-toggle:hover {
  border-color: rgba(79, 124, 255, 0.28);
}

.help-toggle:hover {
  border-color: rgba(79, 124, 255, 0.28);
}

.theme-toggle:hover {
  border-color: rgba(79, 124, 255, 0.28);
}

.theme-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-icon svg {
  width: 20px;
  height: 20px;
}

body[data-theme='light'] .theme-icon.sun {
  display: none;
}

body[data-theme='dark'] .theme-icon.moon {
  display: none;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: calc(var(--top-bar-safe-height) + 24px) 24px 24px;
}

body:not([data-page='preview']) .page-shell {
  align-content: start;
  padding-top: max(calc(var(--top-bar-safe-height) + 64px), calc(50vh - 60px - 180px));
}

.main-card {
  width: min(980px, 100%);
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.hero-header {
  margin-bottom: 22px;
}

.hero-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.08;
  font-weight: 700;
}

.hero-header h1 span:first-child {
  color: #07c16c;
}

.hero-header h2 {
  margin: 12px 0 0;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--muted);
}

.form-card {
  display: block;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

#video-url {
  width: 100%;
  height: 58px;
  min-height: 58px;
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#video-url:hover,
#video-url:focus {
  border-color: #19c16f;
}

#video-url:focus {
  box-shadow: 0 0 0 4px rgba(25, 193, 111, 0.14), var(--shadow);
}

#download-button {
  width: 200px;
  height: 58px;
  min-height: 58px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(20, 184, 106, 0.24);
}

#download-button.is-loading,
#download-button:disabled {
  background: #b6bcc6;
  box-shadow: none;
  opacity: 1;
  cursor: not-allowed;
}

.hint-block {
  margin-top: 22px;
  display: grid;
  gap: 8px;
}

.hint-block p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.status-box {
  margin-top: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  font-size: 0.95rem;
  line-height: 1.7;
}

.status-box.loading {
  color: #7aa2ff;
}

.status-box.success {
  color: #31b870;
}

.status-box.error {
  color: #ff6b7f;
}

.preview-link-wrap {
  margin-top: 8px;
}

.preview-link {
  color: #19c16f;
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: none;
}

.preview-link:hover {
  text-decoration: underline;
}

.progress-wrap {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(20, 184, 106, 0.14);
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #13b868, #30cf7a);
  transition: width 0.25s ease;
}

.progress-text {
  flex: 0 0 auto;
  min-width: 42px;
  color: #19c16f;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: right;
}

.history-panel {
  margin-top: 18px;
}

.seo-content {
  margin-top: 30px;
  display: grid;
  gap: 22px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.seo-section {
  display: grid;
  gap: 10px;
}

.seo-section h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.4;
}

.seo-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
  font-size: 0.95rem;
}

.seo-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  display: grid;
  gap: 8px;
  line-height: 1.8;
  font-size: 0.95rem;
}

.seo-faq-list {
  display: grid;
  gap: 14px;
}

.seo-faq-item {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
}

.seo-faq-item h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
  line-height: 1.5;
}

.seo-faq-item p {
  margin: 0;
}

.disclaimer-block {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(980px, calc(100vw - 36px));
  display: grid;
  gap: 6px;
  text-align: center;
}

.disclaimer-block p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.65;
}

.history-panel h3 {
  margin: 0 0 10px;
  font-size: 0.98rem;
  color: var(--text);
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel);
}

.history-name {
  color: var(--text);
  font-size: 0.94rem;
  word-break: break-all;
}

.history-name-link {
  color: inherit;
  text-decoration: none;
}

.history-name-link:hover {
  text-decoration: underline;
}

.history-name-link.missing {
  color: #ff6b7f;
}

.history-copy-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #3b82f6;
  font-size: 0.9rem;
  cursor: pointer;
}

.history-copy-button:hover {
  text-decoration: underline;
}

.history-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.hidden {
  display: none;
}

.preview-card {
  width: min(980px, 100%);
}

.help-card {
  width: min(980px, 100%);
}

.help-header {
  margin-bottom: 12px;
}

.preview-header {
  margin-bottom: 8px;
}

body[data-page='preview'] .page-shell {
  align-content: start;
  padding-top: calc(var(--top-bar-safe-height) + 16px);
}

.preview-panel {
  display: grid;
  gap: 10px;
}

.preview-info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.preview-info-item {
  min-width: 0;
  padding: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.preview-info-label {
  display: inline;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.preview-info-value {
  display: inline;
  color: var(--text);
  font-size: 0.95rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.preview-video-wrap {
  padding: 0;
}

.preview-video {
  display: block;
  width: 100%;
  max-height: min(50vh, 560px);
  border-radius: 12px;
  background: #000;
  object-fit: contain;
}

.preview-video:fullscreen,
.preview-video:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
}

.preview-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 2px;
}

.preview-secondary-button,
.preview-download-button {
  width: 200px;
  min-height: 58px;
  padding: 0 24px;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 58px;
  text-align: center;
  text-decoration: none;
}

.preview-download-button {
  box-shadow: 0 10px 22px rgba(20, 184, 106, 0.24);
}

.disclaimer-block-preview {
  width: min(980px, 100%);
  margin-top: 12px;
}

.disclaimer-block-help {
  position: static;
  transform: none;
  width: min(980px, 100%);
  margin-top: 20px;
}

.preview-secondary-button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  .page-shell {
    padding: calc(var(--top-bar-safe-height) + 18px) 18px 18px;
  }

  body:not([data-page='preview']) .page-shell {
    padding-top: max(calc(var(--top-bar-safe-height) + 58px), calc(50vh - 60px - 160px));
  }

  .hero-header h1 {
    font-size: 1.9rem;
  }

  .input-row {
    flex-direction: column;
    align-items: stretch;
  }

  #video-url {
    height: 58px;
    min-height: 58px;
  }

  #download-button {
    width: 100%;
    height: 58px;
    min-height: 58px;
  }

  .history-list li {
    align-items: flex-start;
    flex-direction: column;
  }

  .seo-content {
    padding: 18px;
    gap: 18px;
  }

  .top-help-nav {
    top: 72px;
    left: 18px;
    right: 18px;
    transform: none;
    justify-content: flex-start;
    max-width: none;
    gap: 8px;
  }

  .preview-info-grid {
    grid-template-columns: 1fr 1fr;
  }

  .preview-panel {
    gap: 8px;
  }

  body[data-page='preview'] .page-shell {
    padding-top: calc(var(--top-bar-safe-height) + 12px);
  }

  .preview-video {
    max-height: min(42vh, 380px);
  }

  .preview-secondary-button,
  .preview-download-button {
    width: 100%;
  }

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

  .preview-download-button {
    order: 1;
  }

  .preview-secondary-button {
    order: 2;
  }

  .disclaimer-block-preview {
    margin-top: 6px;
  }

  .disclaimer-block {
    width: calc(100vw - 24px);
    bottom: 12px;
  }
}
