:root {
  --bg: #0d1429;
  --card: #141e37;
  --field: #192541;
  --text: #ffffff;
  --secondary: #9eb0c7;
  --accent: #407ad1;
  --accent-soft: #7ad6d6;
  --danger: #ff736b;
  --label: #13203a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 20px 0;
}

.brand {
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--secondary);
}

.lang {
  display: flex;
  background: var(--field);
  border-radius: 999px;
  padding: 3px;
}

.lang button {
  border: 0;
  background: transparent;
  color: var(--secondary);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.lang button[aria-pressed="true"] { background: var(--card); color: var(--text); }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 28px max(32px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 22px;
}

.mark { align-self: center; width: 92px; height: 92px; }

h1 {
  margin: 0;
  text-align: center;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: clamp(28px, 8vw, 34px);
  font-weight: 700;
}

form { display: flex; flex-direction: column; gap: 16px; }

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 8px 0 16px;
  background: var(--field);
  border-radius: 16px;
}

.field:focus-within { outline: 2px solid color-mix(in srgb, var(--accent-soft) 55%, transparent); }

.field-icon { width: 20px; height: 20px; color: var(--secondary); flex: none; }

.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
}

.field input::placeholder { color: color-mix(in srgb, var(--secondary) 70%, transparent); }

.paste {
  border: 0;
  background: var(--card);
  color: var(--accent-soft);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.quality {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--card);
  border-radius: 14px;
  padding: 4px;
}

.quality button {
  border: 0;
  background: transparent;
  color: var(--secondary);
  padding: 9px 0;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.quality button[aria-checked="true"] { background: var(--field); color: var(--text); }

.download {
  position: relative;
  width: 100%;
  height: 56px;
  border: 0;
  border-radius: 999px;
  color: var(--label);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(180deg, #b3edeb 0%, #80d6db 50%, #a3e8e8 100%);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, .9),
    inset 0 -1px 0 rgba(255, 255, 255, .5),
    inset 0 0 0 3px rgba(255, 255, 255, .28);
  transition: transform .22s ease-out, filter .22s ease-out, opacity .2s;
}

.download:active:not(:disabled) {
  transform: scale(.965);
  filter: brightness(.95);
  transition-duration: .12s;
}

.download:disabled { opacity: .42; cursor: default; }

.hint { margin: 0; color: var(--danger); font-size: 15px; }

.jobs { display: flex; flex-direction: column; gap: 10px; }
.jobs:empty { display: none; }

.job {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.job p { margin: 0; }

.job-head { display: flex; align-items: center; gap: 8px; }

.job-number {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--field);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.job-host { font-weight: 600; font-size: 17px; }

.job-url {
  color: var(--secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-status { color: var(--accent); font-weight: 600; font-size: 15px; }
.job.failed .job-status { color: var(--danger); }
.job-error { color: var(--secondary); font-size: 15px; }

.job-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--field);
  overflow: hidden;
}

.job-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .2s;
}

.job-progress.busy span {
  width: 35%;
  animation: slide 1.2s ease-in-out infinite;
}

@keyframes slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(300%); }
}

.job-actions { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: -9px 0 -9px; }
.job-actions:empty { display: none; }

.job-actions a, .job-actions button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 0;
  background: none;
  padding: 0;
  color: #3d9bff;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.job-actions .secondary { color: var(--secondary); }

.note {
  margin: 8px 0 0;
  text-align: center;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
  .download, .download:active:not(:disabled) { transition: none; transform: none; }
  .job-progress.busy span { animation: none; width: 100%; opacity: .5; }
}
