:root {
  color-scheme: light dark;
  --bg: #f5f7fa;
  --ink: #17202a;
  --muted: #5c6673;
  --line: #d8dee7;
  --panel: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.76);
  --field: #fbfcfd;
  --control: #f4f6f8;
  --control-active: #ffffff;
  --media-bg: #dfe5ed;
  --track: #dfe5ed;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #b42318;
  --soft: #eef7f6;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.12);
  --page-wash-a: rgba(15, 118, 110, 0.12);
  --page-wash-b: rgba(205, 133, 63, 0.10);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101418;
  --ink: #eef3f6;
  --muted: #a9b4bd;
  --line: #303a43;
  --panel: #171d23;
  --panel-soft: rgba(23, 29, 35, 0.84);
  --field: #11171d;
  --control: #121920;
  --control-active: #242c34;
  --media-bg: #26313a;
  --track: #303a43;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --warn: #fb7185;
  --soft: rgba(45, 212, 191, 0.13);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.30);
  --page-wash-a: rgba(45, 212, 191, 0.10);
  --page-wash-b: rgba(148, 163, 184, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, var(--page-wash-a), var(--page-wash-b)),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 32px;
}

.workspace {
  width: min(1040px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.eyebrow,
.step {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
}

h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.status-pill {
  min-width: 94px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  min-width: 118px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.theme-toggle:hover {
  background: var(--control-active);
}

.theme-icon {
  font-size: 1rem;
  line-height: 1;
}

.panel {
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.progress-panel {
  scroll-margin-top: 16px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.progress-percent {
  color: var(--accent);
  font-size: 1.2rem;
}

.progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 240ms ease;
}

.progress-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.media-meta {
  color: var(--muted);
  font-weight: 700;
}

label,
legend {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.url-form label {
  display: block;
  margin-bottom: 8px;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

input[type="url"] {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
}

button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.is-hidden {
  display: none;
}

.media-preview {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 96px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.media-preview img {
  width: 168px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  object-fit: cover;
  background: var(--media-bg);
}

.media-preview p {
  margin: 0;
  color: var(--muted);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-width: 440px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
}

.segmented label {
  min-width: 0;
}

.segmented input,
.format-option input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
}

.segmented input:checked + span {
  background: var(--control-active);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(23, 32, 42, 0.14);
}

.choice-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 18px;
  align-items: start;
}

.option-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.option-list.compact {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.format-option {
  position: relative;
  display: block;
  min-width: 0;
  cursor: pointer;
}

.format-option span {
  display: flex;
  min-height: 72px;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.format-option strong {
  color: var(--ink);
  font-size: 1rem;
}

.format-option small {
  color: var(--muted);
  font-size: 0.82rem;
}

.format-option input:checked + span {
  border-color: var(--accent);
  background: var(--soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.muted-field {
  opacity: 0.45;
}

.download-button {
  width: 100%;
  margin-top: 20px;
}

.message {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.message.is-error {
  color: var(--warn);
}

@media (max-width: 720px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .section-head,
  .input-row,
  .media-preview,
  .choice-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    display: grid;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .theme-toggle,
  .status-pill {
    width: 100%;
  }

  .media-preview img {
    width: 100%;
  }

  .segmented {
    max-width: none;
  }
}
