:root {
  color-scheme: light dark;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --text: #1b1d1f;
  --muted: #656d76;
  --border: #d9ded8;
  --accent: #146c5f;
  --accent-strong: #0d5147;
  --danger: #a63434;
  --shadow: 0 16px 40px rgba(25, 31, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

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

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

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3.5rem);
  line-height: 1;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.panel,
.log-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
}

.download-form {
  display: grid;
  gap: 10px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  font: inherit;
}

button,
.download-button,
.secondary,
.danger-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

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

.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.danger-button {
  background: transparent;
  border: 1px solid #e3bcbc;
  color: var(--danger);
}

.danger-button:hover {
  background: #f8dddd;
}

.history {
  margin-top: 24px;
}

.job-list {
  display: grid;
  gap: 10px;
}

.job-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.job-card form {
  margin: 0;
}

.job-link {
  min-width: 0;
  display: grid;
  gap: 6px;
  text-decoration: none;
}

.status {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8ece7;
  color: #2e3934;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status.done {
  background: #dff3ea;
  color: #0d604c;
}

.status.failed {
  background: #f8dddd;
  color: var(--danger);
}

.job-url,
.source-url {
  color: var(--text);
  margin: 0;
}

.job-file,
.muted {
  color: var(--muted);
  margin: 0;
  font-size: 0.92rem;
}

.error {
  color: var(--danger);
  margin: 0;
}

.download-button {
  width: 100%;
  min-height: 52px;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-button {
  min-height: 52px;
  width: 100%;
}

.delete-form {
  margin-top: 14px;
}

.delete-form button {
  width: 100%;
}

.video-player {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 8px;
}

.progress {
  height: 8px;
  overflow: hidden;
  background: #e6ebe8;
  border-radius: 999px;
}

.progress span {
  display: block;
  width: 45%;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  animation: loading 1.1s ease-in-out infinite alternate;
}

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

pre {
  margin: 0;
  max-height: 48vh;
  overflow: auto;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.82rem;
  line-height: 1.45;
}

@keyframes loading {
  from {
    transform: translateX(-60%);
  }
  to {
    transform: translateX(170%);
  }
}

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

  .input-row {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .job-card,
  .action-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413;
    --surface: #181d1b;
    --text: #eef2ef;
    --muted: #a4ada8;
    --border: #303835;
    --shadow: none;
  }

  input {
    background: #111413;
  }

  .status {
    background: #26302c;
    color: #dce5e0;
  }

  .danger-button:hover {
    background: #351f22;
  }

  .progress {
    background: #26302c;
  }
}
