:root {
  color-scheme: light;
  --page: #eef6ff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --soft: #f3f7ff;
  --text: #121827;
  --muted: #5f6f8b;
  --line: #dbe8f7;
  --primary: #6d5cff;
  --primary-strong: #4e40e8;
  --cyan: #00b8ff;
  --green: #00d18f;
  --orange: #ff7a1a;
  --pink: #ff3fa4;
  --shadow: 0 28px 78px rgba(21, 31, 62, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 43% 18%, rgba(109, 92, 255, 0.24), transparent 23%),
    radial-gradient(circle at 69% 18%, rgba(0, 184, 255, 0.2), transparent 21%),
    radial-gradient(circle at 72% 43%, rgba(255, 63, 164, 0.13), transparent 18%),
    linear-gradient(180deg, #fbfdff 0%, #edf6ff 58%, #ffffff 58%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

body.dark-mode {
  --page: #0f172a;
  --surface: rgba(20, 27, 43, 0.88);
  --surface-solid: #151d2f;
  --soft: #202a40;
  --text: #f7f9ff;
  --muted: #aab4c7;
  --line: #303b52;
  background:
    radial-gradient(circle at 42% 18%, rgba(102, 87, 242, 0.3), transparent 22%),
    radial-gradient(circle at 68% 18%, rgba(14, 165, 233, 0.2), transparent 20%),
    linear-gradient(180deg, #0f172a 0%, #111827 58%, #0f172a 58%);
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.ambient span {
  position: absolute;
  width: 210px;
  height: 210px;
  border-radius: 999px;
  opacity: 0.42;
  filter: blur(48px);
  animation: drift 11s ease-in-out infinite alternate;
}

.ambient span:nth-child(1) {
  top: 16%;
  left: 43%;
  background: #8a7bff;
}

.ambient span:nth-child(2) {
  top: 14%;
  right: 18%;
  animation-delay: -4s;
  background: #20d4ff;
}

.ambient span:nth-child(3) {
  top: 38%;
  right: 31%;
  animation-delay: -8s;
  background: #ff77c7;
}

@keyframes drift {
  from {
    transform: translate3d(-12px, -8px, 0) scale(0.95);
  }
  to {
    transform: translate3d(16px, 14px, 0) scale(1.08);
  }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(430px, 1fr) auto;
  align-items: center;
  min-height: 58px;
  padding: 0 22px 0 30px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.86);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px);
}

body.dark-mode .site-header {
  background: rgba(15, 23, 42, 0.78);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  color: var(--text);
  text-decoration: none;
}

.brand-symbol {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6d5cff, #00c8ff);
  color: #fff;
  box-shadow: 0 12px 30px rgba(102, 87, 242, 0.3);
}

.brand-symbol svg {
  width: 18px;
  height: 18px;
}

.brand strong {
  display: block;
  overflow: hidden;
  max-width: 188px;
  font-size: 20px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong span {
  color: var(--primary);
  text-shadow: 0 0 18px rgba(109, 92, 255, 0.32);
}

.brand small {
  display: block;
  overflow: hidden;
  max-width: 188px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-nav,
.header-actions {
  display: flex;
  align-items: center;
}

.top-nav {
  justify-content: center;
  gap: 10px;
}

.nav-item {
  position: relative;
}

.nav-trigger,
.header-action,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  font-size: 14px;
}

.nav-trigger:hover,
.nav-trigger.active,
.header-action:hover {
  color: var(--primary-strong);
  background: rgba(102, 87, 242, 0.08);
}

.nav-trigger svg,
.header-action svg,
.theme-toggle svg {
  width: 16px;
  height: 16px;
}

.nav-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  display: none;
  min-width: 240px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.nav-item:hover .nav-menu,
.nav-item:focus-within .nav-menu {
  display: grid;
}

.nav-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
}

.nav-menu button svg {
  flex: 0 0 auto;
}

.nav-menu button:hover {
  background: var(--soft);
  color: var(--primary-strong);
}

.header-actions {
  justify-content: flex-end;
  gap: 4px;
}

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface-solid);
}

.theme-toggle strong {
  min-width: 38px;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  text-align: center;
}

.quick-entry {
  position: fixed;
  top: 76px;
  right: 30px;
  z-index: 30;
  width: 340px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.quick-entry[hidden] {
  display: none;
}

.quick-close,
.popover-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--muted);
}

.quick-entry p,
.quick-entry h2,
.quick-entry span {
  display: block;
  margin: 0;
}

.quick-entry p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.quick-entry h2 {
  margin-top: 8px;
  font-size: 26px;
}

.quick-entry > span {
  margin-top: 12px;
  color: var(--muted);
}

#quickActions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

#quickActions button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-solid);
  color: var(--text);
  font-weight: 800;
}

#quickActions button:hover {
  border-color: rgba(102, 87, 242, 0.45);
  color: var(--primary-strong);
}

.tool-sidebar {
  position: fixed;
  z-index: 25;
  top: 58px;
  bottom: 0;
  left: 0;
  width: 178px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

body.dark-mode .tool-sidebar {
  background: rgba(15, 23, 42, 0.86);
}

.sidebar-scroll {
  height: 100%;
  overflow: auto;
  padding: 16px 8px 26px;
}

.sidebar-group {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.sidebar-title {
  margin: 0 0 4px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.sidebar-tool {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
}

.sidebar-tool svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--tool-color, var(--primary));
}

.sidebar-tool span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-tool:hover,
.sidebar-tool.active {
  background: rgba(102, 87, 242, 0.1);
  color: var(--primary-strong);
  font-weight: 900;
}

.sidebar-tool.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.page {
  margin-left: 178px;
}

.hero-tool {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 482px);
  align-items: center;
  gap: clamp(34px, 7vw, 96px);
  min-height: 598px;
  padding: 74px max(6vw, 42px) 82px;
}

.tool-intro {
  justify-self: end;
  min-width: 0;
  width: min(540px, 100%);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.badges span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.badges svg {
  width: 15px;
  height: 15px;
}

.badges span:nth-child(1) svg {
  color: var(--primary);
}

.badges span:nth-child(2) svg {
  color: var(--green);
}

.badges span:nth-child(3) svg {
  color: var(--cyan);
}

.badges span:nth-child(4) svg {
  color: var(--orange);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-bubble {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border-radius: 24px;
  background:
    linear-gradient(var(--surface-solid), var(--surface-solid)) padding-box,
    linear-gradient(135deg, var(--primary), var(--cyan), var(--pink)) border-box;
  border: 1px solid transparent;
  color: var(--primary);
  box-shadow: 0 18px 50px rgba(102, 87, 242, 0.18);
}

.icon-bubble svg {
  width: 34px;
  height: 34px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

.tool-intro h1 {
  margin: 0;
  font-size: clamp(48px, 5.6vw, 72px);
  line-height: 0.98;
}

.lead {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1.5;
}

.upload-card,
.result-panel,
.steps-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, rgba(109, 92, 255, 0.3), rgba(0, 184, 255, 0.24), rgba(255, 63, 164, 0.18)) border-box;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.upload-card {
  min-width: 0;
  overflow: hidden;
  padding: 28px;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 286px;
  border: 1.5px dashed #d6dce8;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.58);
  text-align: center;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

body.dark-mode .dropzone {
  background: rgba(15, 23, 42, 0.36);
}

.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(102, 87, 242, 0.08);
  transform: translateY(-2px);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.drop-inner {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 20px;
}

.upload-orb {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 999px;
  color: var(--primary);
  background: rgba(102, 87, 242, 0.12);
  animation: pulse 2.8s ease-in-out infinite;
}

.upload-orb svg {
  width: 32px;
  height: 32px;
}

@keyframes pulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.04);
  }
}

.drop-inner strong {
  font-size: 18px;
}

.drop-inner span:last-child {
  color: var(--muted);
  line-height: 1.45;
}

.url-tool {
  display: grid;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.url-tool > span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.url-tool > span::before,
.url-tool > span::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.url-tool div {
  display: grid;
  grid-template-columns: 1fr 82px;
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-solid);
}

.url-tool input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 0 14px;
  text-overflow: ellipsis;
}

.url-tool button {
  min-height: 42px;
  border: 0;
  background: linear-gradient(135deg, #7768ff, #b49dff);
  color: #fff;
  font-weight: 900;
}

.file-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.file-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-solid);
}

.file-row span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row span:last-child {
  flex: 0 0 auto;
  color: var(--muted);
  white-space: nowrap;
}

.settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.setting {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.setting label {
  font-size: 13px;
  font-weight: 900;
}

.setting input,
.setting select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-solid);
  color: var(--text);
  padding: 0 12px;
}

.setting small {
  grid-column: 1 / -1;
  color: var(--muted);
  line-height: 1.45;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 10px;
  padding: 0 16px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 900;
}

.primary-button {
  background: linear-gradient(135deg, #6657f2, #8f78ff);
  color: #fff;
  box-shadow: 0 14px 30px rgba(102, 87, 242, 0.24);
}

.ghost-button {
  background: var(--surface-solid);
  border-color: var(--line);
  color: var(--text);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.result-section {
  display: grid;
  gap: 42px;
  padding: 66px max(6vw, 42px) 90px;
  background: #fff;
}

body.dark-mode .result-section {
  background: #101827;
}

.result-panel {
  width: min(920px, 100%);
  justify-self: center;
  display: grid;
  gap: 16px;
  padding: 22px;
}

.status-card,
.download-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  background: var(--soft);
}

.status-card h2 {
  margin: 0;
}

#engineStatus {
  color: var(--muted);
  white-space: nowrap;
}

.progress-area {
  display: grid;
  gap: 12px;
}

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ebf4;
}

#progressFill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--green), var(--orange));
  transition: width 0.2s ease;
}

#logOutput {
  min-height: 190px;
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  background: #10151c;
  color: #d9f4e7;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.download-card strong,
.download-card span {
  display: block;
  overflow: hidden;
  max-width: min(62vw, 560px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-card span {
  color: var(--muted);
  margin-top: 4px;
}

.preview-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d1117;
  overflow: hidden;
}

.preview-card video,
.preview-card img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.preview-card audio {
  width: 100%;
  padding: 16px;
}

.steps-panel {
  width: min(980px, 100%);
  justify-self: center;
  padding: 30px;
  text-align: center;
  box-shadow: none;
}

.section-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(102, 87, 242, 0.1);
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.steps-panel h2 {
  margin: 20px 0 34px;
  font-size: clamp(34px, 4vw, 48px);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px;
}

.steps div {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
}

.steps strong {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  box-shadow: 0 14px 30px rgba(102, 87, 242, 0.22);
}

.steps div:nth-child(2) strong {
  background: var(--green);
}

.steps div:nth-child(3) strong {
  background: var(--orange);
}

.steps h3,
.steps p {
  margin: 0;
}

.steps p {
  color: var(--muted);
  line-height: 1.65;
}

.popover {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: start end;
  padding: 76px 34px;
  background: rgba(15, 23, 42, 0.18);
}

.popover[hidden] {
  display: none;
}

.popover-card {
  position: relative;
  width: min(380px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.popover-card h2 {
  margin: 0 0 10px;
  font-size: 26px;
}

.popover-card p {
  color: var(--muted);
  line-height: 1.7;
}

.popover-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.popover-actions button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-solid);
  color: var(--text);
  font-weight: 900;
}

.popover-actions button:hover {
  border-color: rgba(102, 87, 242, 0.55);
  color: var(--primary-strong);
}

@media (max-width: 1220px) {
  .site-header {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px 18px;
  }

  .top-nav,
  .header-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .tool-sidebar {
    top: 132px;
  }

  .hero-tool {
    grid-template-columns: 1fr;
  }

  .tool-intro {
    justify-self: start;
  }

  .quick-entry {
    display: none;
  }
}

@media (max-width: 820px) {
  .tool-sidebar {
    position: static;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 10px 14px;
  }

  .sidebar-group {
    min-width: 170px;
    border-bottom: 0;
    margin: 0;
    padding: 0;
  }

  .page {
    margin-left: 0;
  }

  .hero-tool,
  .result-section {
    padding-left: 18px;
    padding-right: 18px;
  }

  .settings,
  .steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .top-nav,
  .header-actions {
    display: none;
  }

  .site-header {
    display: flex;
    justify-content: space-between;
  }

  .tool-intro h1 {
    font-size: 42px;
  }

  .title-row,
  .status-card,
  .download-card,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .upload-card,
  .result-panel,
  .steps-panel {
    padding: 18px;
  }
}
