:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #000;
  --field: #171717;
  --field-hover: #1c1c1c;
  --line: #292929;
  --muted: #777;
  --soft: #c5c1bb;
  --text: #f4f1ea;
  --success: #b8f16b;
  --danger: #ff7669;
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.shell {
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 48px 0;
}

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

.mode-switch {
  width: fit-content;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 22px;
  padding: 4px;
  border-radius: 12px;
  background: #101010;
}

.mode-button {
  min-width: 150px;
  border: 0;
  border-radius: 9px;
  padding: 12px 18px;
  background: transparent;
  color: #777;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 760;
  letter-spacing: .04em;
}

.mode-button.active { background: #f1eee8; color: #0a0a0a; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(310px, .75fr);
  gap: 20px;
}

.form-panel,
.preview-panel,
.results-panel {
  border-radius: var(--radius);
  background: var(--panel);
}

.form-panel { padding: clamp(26px, 4vw, 52px); }

.field-heading,
.step-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 13px;
  color: var(--soft);
  font-size: .86rem;
  font-weight: 650;
}

.platform-pill,
.eyebrow {
  color: #737373;
  font: 700 .66rem/1.2 Arial, Helvetica, sans-serif;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.platform-pill.detected { color: var(--success); }

.url-wrap {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  min-height: 66px;
  border-radius: 12px;
  background: var(--field);
  transition: background .2s, box-shadow .2s;
}

.url-wrap:focus-within,
.file-drop:focus-within { background: var(--field-hover); box-shadow: 0 0 0 3px rgba(255, 255, 255, .045); }

.link-icon { display: grid; place-items: center; color: #737373; }
.link-icon svg { width: 20px; }

#media-url {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0 20px 0 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
}

#media-url::placeholder { color: #555; }

.support-copy {
  margin: 11px 2px 0;
  color: #565656;
  font-size: .7rem;
  line-height: 1.5;
}

.selection-area { margin-top: 30px; }

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.format-tabs {
  min-height: 55px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 5px;
  padding: 5px;
  border-radius: 12px;
  background: var(--field);
}

.format-tab {
  border: 0;
  border-radius: 8px;
  padding: 13px;
  background: transparent;
  color: #797979;
  cursor: pointer;
  font-weight: 760;
  letter-spacing: .05em;
}

.format-tab.active { background: #f1eee8; color: #0b0b0b; }

.select-wrap { position: relative; }

.select-wrap select {
  width: 100%;
  height: 55px;
  appearance: none;
  border: 0;
  border-radius: 12px;
  outline: 0;
  padding: 0 42px 0 17px;
  background: var(--field);
  color: #ddd9d2;
  cursor: pointer;
}

.select-wrap::after {
  content: "↓";
  position: absolute;
  top: 17px;
  right: 17px;
  color: #696969;
  pointer-events: none;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 28px;
}

.primary-button {
  position: relative;
  flex: 1;
  min-height: 60px;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  padding: 0 24px;
  background: #f5f5f3;
  color: #0a0a0a;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  transition: background .2s, transform .2s, opacity .2s;
}

.primary-button:hover { background: #fff; }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: wait; opacity: .68; }

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  margin-left: 10px;
  border: 2px solid #888;
  border-top-color: #090909;
  border-radius: 50%;
  vertical-align: -3px;
  animation: spin .7s linear infinite;
}

.primary-button.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.privacy {
  max-width: 190px;
  margin: 0;
  color: #686868;
  font-size: .72rem;
  line-height: 1.45;
}

.preview-panel {
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.empty-state {
  flex: 1;
  display: grid;
  place-content: center;
  padding: 34px;
  text-align: center;
}

.empty-state h2 { margin: 0 0 9px; font-size: 1rem; }
.empty-state p { max-width: 280px; margin: 0; color: #666; font-size: .84rem; line-height: 1.6; }

.preview-card {
  flex: 1;
  padding: 28px;
  animation: rise .35s ease both;
}

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

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: #151515;
}

.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.no-image { display: none; }

.duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border-radius: 5px;
  padding: 5px 7px;
  background: rgba(0, 0, 0, .84);
  font: 600 .7rem/1 Arial, Helvetica, sans-serif;
}

.preview-meta { padding-top: 21px; }
.preview-meta .eyebrow { display: block; margin-bottom: 9px; color: var(--success); }

.preview-meta h2,
.track-card h2 {
  overflow-wrap: anywhere;
  margin: 0 0 8px;
  font-size: 1.08rem;
  line-height: 1.45;
}

.preview-meta p,
.track-card p { margin: 0; color: #777; font-size: .82rem; }

.file-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: auto 0 0;
  padding-top: 24px;
}

.summary-item { border-top: 1px solid #252525; padding-top: 13px; }
.summary-item dt { color: #606060; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; }
.summary-item dd { margin: 7px 0 0; font: 650 .78rem/1.3 Arial, Helvetica, sans-serif; }

.results-panel { margin-top: 20px; padding: clamp(24px, 4vw, 42px); }

.results-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.results-heading h2 { margin: 7px 0 0; font-size: 1.15rem; }

.text-button {
  border: 0;
  padding: 7px 0;
  background: transparent;
  color: #8f8f8f;
  cursor: pointer;
  font-size: .75rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.download-list { display: grid; gap: 8px; }

.download-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 68px;
  padding: 13px 16px 13px 19px;
  border-radius: 11px;
  background: #141414;
}

.download-copy { min-width: 0; }
.download-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.download-copy span { display: block; margin-top: 5px; color: #6f6f6f; font-size: .72rem; }

.download-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  border-radius: 8px;
  padding: 0 14px;
  background: #f1eee8;
  color: #0a0a0a;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.expiry-note { margin: 15px 2px 0; color: #626262; font-size: .72rem; line-height: 1.5; }

.file-drop {
  min-height: 200px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  border-radius: 14px;
  background: var(--field);
  cursor: pointer;
  text-align: center;
}

.file-drop.dragging { background: #202020; box-shadow: 0 0 0 2px var(--success); }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-plus { color: #696969; font-size: 2rem; font-weight: 200; line-height: 1; }
.file-drop strong { max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .94rem; }
.file-drop > span:last-child { color: #676767; font-size: .74rem; }

.track-card { flex: 1; padding: 30px; animation: rise .35s ease both; }
.cover { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; margin-bottom: 22px; background: #151515; }
.track-card .eyebrow { display: block; margin-bottom: 9px; color: var(--success); }
.track-details { display: grid; gap: 8px; margin: 21px 0; }
.track-detail { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid #252525; padding-top: 9px; color: #717171; font-size: .74rem; }
.track-detail strong { color: #bdbdbd; font-weight: 600; text-align: right; }
.secondary-link { width: 100%; }

.toast {
  position: fixed;
  z-index: 10;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100vw - 48px));
  border: 1px solid #353535;
  border-radius: 11px;
  padding: 14px 16px;
  background: #151515;
  color: #ddd;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
  font-size: .82rem;
  line-height: 1.4;
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
}

.toast.error { border-color: #552d29; color: var(--danger); }
.toast.show { transform: none; opacity: 1; }

@media (max-width: 820px) {
  .shell { width: min(100% - 28px, 680px); padding: 28px 0; }
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { min-height: 350px; }
}

@media (max-width: 540px) {
  .mode-switch { width: 100%; }
  .mode-button { min-width: 0; padding-inline: 10px; }
  .options-grid { grid-template-columns: 1fr; }
  .action-row { display: block; }
  .privacy { max-width: none; margin: 14px 4px 0; }
  .url-wrap { grid-template-columns: 42px 1fr; }
  .results-heading { align-items: start; }
  .download-item { grid-template-columns: 1fr; }
  .download-link { width: 100%; }
}

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