﻿:root {
  color-scheme: dark;
  --page: #101016;
  --panel: #17171f;
  --inset: #121219;
  --border: #2c2b39;
  --border-strong: #403b50;
  --ink: #f7f4ff;
  --muted: #b0abbf;
  --soft: #9b95ae;
  --accent: #b39bff;
  --accent-ink: #1d103b;
  --success: #85e8b7;
  --error: #ffb3bf;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 280px; scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, input, select, a { -webkit-tap-highlight-color: transparent; }
button, select, summary { cursor: pointer; }
button:disabled, fieldset:disabled select { cursor: default; }
button:disabled { opacity: .6; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, p { margin: 0; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; }

.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  display: block;
  flex: none;
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.site-width { width: min(100% - var(--gutter) * 2, 70rem); margin-inline: auto; }

.topbar {
  position: relative;
  z-index: 1;
  border-bottom: 1px solid #24232e;
  background: #111117;
}
.topbar-inner, .topbar-actions, .brand, .help-link, .engine-status {
  display: flex;
  align-items: center;
}
.topbar-inner { min-height: 4.5rem; justify-content: space-between; gap: 1rem; }
.brand { flex: none; gap: .65rem; font-size: 1.13rem; font-weight: 650; letter-spacing: -.035em; }
.brand img { display: block; flex: none; }
.brand strong { color: var(--accent); font-weight: inherit; }
.topbar-actions { gap: 1.35rem; }
.help-link { gap: .4rem; min-height: 2.75rem; color: var(--muted); font-size: .875rem; }
.help-link:hover { color: var(--ink); }
.engine-status {
  gap: .48rem;
  min-height: 2rem;
  padding: .28rem .7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #17171f;
  color: var(--muted);
  white-space: nowrap;
  font-size: .8rem;
  font-weight: 600;
}
.status-dot { width: .45rem; height: .45rem; flex: none; border-radius: 50%; background: #e7c180; }
.engine-status[data-status="online"] { color: #aaeac9; }
.engine-status[data-status="online"] .status-dot { background: var(--success); box-shadow: 0 0 .65rem #85e8b755; }
.engine-status[data-status="offline"] .status-dot { background: #fe91a6; }

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  place-content: center;
  gap: .72rem;
  min-height: 14.25rem;
  padding-block: 2.25rem 2.5rem;
  text-align: center;
}
.hero-grid {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg, #986af820 1px, transparent 1px),
    linear-gradient(#986af81a 1px, transparent 1px),
    radial-gradient(ellipse at center, #251940 8%, transparent 68%);
  background-size: 2.5rem 2.5rem, 2.5rem 2.5rem, 100% 100%;
  background-position: center;
  mask-image: radial-gradient(ellipse at center, black 3%, transparent 73%);
  pointer-events: none;
}
.hero-orbit {
  position: absolute;
  z-index: -1;
  top: 49%;
  width: 3.25rem;
  aspect-ratio: 1;
  border: 1px solid #a78cf239;
  border-radius: .9rem;
  transform: rotate(18deg);
  box-shadow: 0 0 2.5rem #8662da15, inset 0 0 1.6rem #8662da15;
}
.hero-orbit::before, .hero-orbit::after {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 1.1rem;
  height: 1px;
  transform: translate(-50%, -50%);
  background: #b29af682;
  content: "";
}
.hero-orbit::after { transform: translate(-50%, -50%) rotate(90deg); }
.hero-orbit-left { left: 8%; }
.hero-orbit-right { top: 29%; right: 8%; transform: rotate(-18deg); }
.hero h1 {
  font-size: clamp(2.55rem, 6.9vw, 5.65rem);
  font-weight: 720;
  line-height: 1.04;
  letter-spacing: -.067em;
  text-wrap: balance;
}
.hero h1 span {
  color: #bc9fff;
  background: linear-gradient(110deg, #d4c4ff 4%, #a886fb 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p { color: var(--muted); font-size: clamp(1rem, 2.2vw, 1.2rem); text-wrap: balance; }

.workspace { display: grid; grid-template-columns: minmax(0, 2.25fr) minmax(18rem, 1fr); gap: 1.35rem; align-items: start; }
.panel { min-width: 0; border: 1px solid var(--border); border-radius: 1.25rem; background: var(--panel); }
.converter { padding: clamp(1rem, 3vw, 1.85rem); box-shadow: 0 1rem 3rem #06060b4d; }
.panel-header { display: flex; align-items: center; gap: .72rem; min-width: 0; }
.panel-header h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -.025em; }
.converter > .panel-header h2 { font-size: clamp(1.16rem, 2.8vw, 1.36rem); }
.panel-icon, .result-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid #41335f;
  border-radius: .66rem;
  background: #27203b;
  color: #c3adff;
}
.converter > .panel-header .panel-icon { width: 2.7rem; height: 2.7rem; }

.converter-fields { margin-top: 1.45rem; }
.field-label { display: block; margin-bottom: .48rem; color: var(--ink); font-size: .9rem; font-weight: 650; }
.source-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .45rem; }
.url-field, .select-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 3.05rem;
  border: 1px solid var(--border-strong);
  border-radius: .68rem;
  background: var(--inset);
}
.url-field:focus-within, .select-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px #ad91fd29; }
.url-field:has(input[aria-invalid="true"]) { border-color: #ba6b82; }
.url-field input {
  min-width: 0;
  width: 100%;
  min-height: 3rem;
  padding: 0 .75rem 0 .5rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}
.url-field input::placeholder { color: var(--soft); }
.platform-icon { display: grid; place-items: center; flex: none; width: 1.4rem; margin-left: .7rem; color: var(--soft); }
.platform-glyph { display: block; width: 1.1rem; height: 1.1rem; fill: currentColor; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .52rem;
  min-height: 2.75rem;
  padding: .48rem .82rem;
  border: 1px solid transparent;
  border-radius: .68rem;
  color: inherit;
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
}
.button-subtle { border-color: var(--border-strong); background: #201f2a; }
.button-subtle:is(:hover, :focus-visible):not(:disabled) { border-color: #726092; background: #2a253a; }
.paste-button { padding-inline: .68rem; color: var(--muted); }
.analyze-button { color: #d5c6ff; }
.button-primary {
  border-color: #c4b1ff;
  background: linear-gradient(113deg, #c2adff, #a685ff);
  color: var(--accent-ink);
  box-shadow: 0 .25rem 1rem #8661ee26, inset 0 1px #f0e8ff53;
}
.button-primary:hover:not(:disabled) { background: #ccbaff; }
.field-hint, .field-error, .retention-note { margin-top: .52rem; color: var(--muted); font-size: .84rem; }
.field-error, .global-error { color: var(--error); }
.converter-fields:disabled .choice-field, .converter-fields:disabled .quality-field { opacity: .7; }

.source-preview {
  display: flex;
  align-items: center;
  gap: .9rem;
  min-width: 0;
  margin-top: .85rem;
  padding: .65rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: #13131b;
}
.thumbnail-wrap {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: clamp(4.25rem, 16vw, 7.5rem);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: .45rem;
  background: #242039;
  color: var(--accent);
}
.thumbnail-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumbnail-wrap span:not(:empty) {
  position: absolute;
  right: .22rem;
  bottom: .22rem;
  padding: .02rem .24rem;
  border-radius: .22rem;
  background: #09090ecf;
  color: var(--ink);
  font-size: .74rem;
  font-variant-numeric: tabular-nums;
}
.preview-meta { display: grid; gap: .16rem; min-width: 0; }
.preview-meta strong { overflow: hidden; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
.preview-meta span { overflow: hidden; color: var(--muted); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.preview-meta .preview-label { color: var(--accent); font-weight: 650; }

.output-section { display: grid; gap: 1rem; margin-top: 1.15rem; padding-top: 1.15rem; border-top: 1px solid var(--border); }
.segment, .format-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.segment { max-width: 17.5rem; padding: .25rem; border: 1px solid var(--border); border-radius: .72rem; background: var(--inset); }
.segment label, .format-options label { position: relative; min-width: 0; }
.segment input, .format-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.segment label > span, .format-options label > span {
  display: flex;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: .52rem;
  transition: background-color .14s, border-color .14s;
}
.segment label > span {
  align-items: center;
  justify-content: center;
  gap: .52rem;
  min-height: 2.55rem;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 650;
}
.segment input:checked + span { border-color: #544175; background: #302645; color: #eddfff; }
.segment input:disabled + span { cursor: default; }
.segment input:disabled:not(:checked) + span { opacity: .55; }
.segment input:focus-visible + span, .format-options input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.format-options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }
.video-formats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.format-options label > span {
  flex-direction: column;
  justify-content: center;
  gap: .14rem;
  min-height: 4.1rem;
  height: 100%;
  padding: .52rem .7rem;
  border-color: var(--border);
  border-radius: .7rem;
  background: var(--inset);
}
.format-options input:checked + span { border-color: #9b7bec; background: #272039; }
.format-options input:not(:disabled) + span:hover { border-color: #9b7bec; }
.format-options input:disabled + span { cursor: default; }
.format-options strong { font-size: .93rem; letter-spacing: -.018em; }
.format-options small { color: var(--muted); font-size: .81rem; line-height: 1.2; }

.select-wrap { position: relative; width: 100%; }
.select-wrap::after, summary::after {
  width: .5rem;
  height: .5rem;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: rotate(45deg);
  content: "";
}
.select-wrap::after { position: absolute; right: 1rem; top: calc(50% - .35rem); pointer-events: none; }
select {
  appearance: none;
  width: 100%;
  min-height: 3rem;
  padding: .4rem 2.4rem .4rem .8rem;
  border: 0;
  outline: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--ink);
}
option { background: var(--inset); }

.form-actions { margin-top: 1.2rem; }
.form-actions .button-primary { width: 100%; min-height: 3.15rem; font-size: .95rem; }
.retention-note { display: flex; align-items: center; justify-content: center; gap: .4rem; margin-top: .68rem; text-align: center; }
.global-error, .job-panel { margin-top: .95rem; padding: .9rem; border: 1px solid #53416c; border-radius: .8rem; background: #211a30; }
.global-error { border-color: #643a4b; background: #2e1b26; font-size: .9rem; }
.job-notice { margin-top: .9rem; text-align: center; }
.job-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.job-heading > div { min-width: 0; }
.job-heading p { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
#progressPercent { flex: none; color: #e3d6ff; font-variant-numeric: tabular-nums; font-size: .9rem; }
progress { display: block; width: 100%; height: .45rem; margin-top: .75rem; overflow: hidden; appearance: none; border: 0; border-radius: 10px; background: #39304b; }
progress::-webkit-progress-bar { border-radius: 10px; background: #39304b; }
progress::-webkit-progress-value { border-radius: 10px; background: #bd9dff; }
progress::-moz-progress-bar { border-radius: 10px; background: #bd9dff; }
progress:indeterminate { background: repeating-linear-gradient(115deg, #39304b 0 .55rem, #67528e .55rem 1rem); }
progress:indeterminate::-webkit-progress-bar { background: transparent; }
.job-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; margin-top: .75rem; }
.result-panel { background: #182823; border-color: #335a49; }
.result-panel .job-heading { justify-content: flex-start; }
.result-icon { border-color: #3c6655; background: #213a30; color: var(--success); }
.result-panel .button-primary { border-color: #a1ecc6; background: #9ce5be; color: #10271e; }
.result-panel .button-primary:hover { background: #baefd3; }

.sidebar { display: grid; gap: 1rem; }
.side-panel { padding: 1.1rem; }
.platform-count { margin-left: auto; padding: .1rem .45rem; border: 1px solid var(--border); border-radius: .4rem; color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; }
.platform-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .42rem; margin: .85rem 0 0; padding: 0; list-style: none; }
.platform-list li {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 2.65rem;
  gap: .4rem;
  padding: .3rem .38rem;
  border: 1px solid #2b2937;
  border-radius: .58rem;
  background: #14141c;
  color: #eae4f8;
  overflow-wrap: anywhere;
  font-size: .81rem;
  font-weight: 550;
}
.platform-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: .4rem;
  background: color-mix(in srgb, currentColor 11%, #16151e);
}
.platform-mark .platform-glyph { width: .92rem; height: .92rem; }
summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: 2.75rem;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::after { flex: none; margin-right: .18rem; margin-top: -.24rem; }
details[open] > summary::after { transform: rotate(225deg); margin-top: .24rem; }
summary:hover { color: var(--ink); }
.platform-disclosure { margin-top: .46rem; }
.platform-disclosure summary { color: #cdbaff; }
.platform-disclosure .platform-list { margin-top: .1rem; }
.help-panel { scroll-margin-top: 1rem; }
.help-panel .panel-header { margin-bottom: .65rem; }
.help-panel details { border-top: 1px solid var(--border); }
.help-panel details p { padding: 0 .3rem .7rem 0; color: var(--muted); font-size: .86rem; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .45rem 1rem;
  margin-top: 2rem;
  padding-block: 1.15rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--soft);
  font-size: .83rem;
}
.site-footer > span { color: var(--muted); font-weight: 650; }

@media (max-width: 61rem) {
  .hero-orbit-left { left: 2%; }
  .hero-orbit-right { right: 2%; }
  .workspace { gap: 1rem; }
}
@media (max-width: 54rem) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (max-width: 40rem) {
  .topbar-inner { min-height: 3.85rem; }
  .topbar-actions { gap: .65rem; }
  .brand { font-size: 1rem; gap: .48rem; }
  .brand img { width: 2.15rem; height: 2.15rem; }
  .hero { gap: .55rem; min-height: 10rem; padding-block: 1.35rem; }
  .hero h1 { letter-spacing: -.06em; }
  .hero-orbit { display: none; }
  .sidebar { grid-template-columns: minmax(0, 1fr); }
  .converter-fields { margin-top: 1.15rem; }
  .source-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .url-field { grid-column: 1 / -1; }
  .output-section { gap: .84rem; margin-top: .9rem; padding-top: .9rem; }
  .form-actions { margin-top: .95rem; }
}
@media (max-width: 30rem) {
  .help-link { justify-content: center; width: 2.15rem; font-size: 0; gap: 0; }
  .help-link .icon { font-size: 1.05rem; }
  .hero { min-height: 9rem; padding-block: 1.05rem 1.2rem; }
  .hero h1 { font-size: clamp(2rem, 8.2vw, 2.55rem); }
  .hero p { max-width: 25rem; }
  .format-options label > span { padding-inline: .43rem; }
  .format-options small { font-size: .76rem; }
  .converter, .side-panel { border-radius: 1rem; }
  .result-panel .job-actions > * { flex: 1 1 8rem; }
}
@media (max-width: 22rem) {
  .help-link { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
