:root {
  color-scheme: dark;
  --bg: #12140f;
  --bg-raised: #1b1e16;
  --line: #31362a;
  --text: #f6f3ea;
  --muted: #a8ad9d;
  --accent: #e3f08a;
  --accent-ink: #1a1e0d;
  --danger: #ffc7bc;
  --ok: #c7ecb4;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI Variable", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  overflow-x: clip;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(227, 240, 138, 0.14), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(120, 92, 48, 0.18), transparent 55%),
    var(--bg);
}

main {
  width: min(760px, calc(100% - 32px));
  max-width: 100%;
  margin: 0 auto;
  padding: 48px 0 64px;
}

.mark {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 44px;
  line-height: 1.05;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.lead {
  max-width: 62ch;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

form, .preview, .library {
  margin-top: 28px;
  min-width: 0;
  max-width: 100%;
}

.url-field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  color: var(--text);
  background: #171a13;
  font: inherit;
  font-size: 16px;
}

input[type="text"]::placeholder { color: #6f7466; }

.form-row, .library-head, .file-row, .card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 15px;
}

.check input { width: 18px; height: 18px; accent-color: #c6dc62; }

button, .text-btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

button[type="submit"], #download, .text-btn.primary {
  color: var(--accent-ink);
  background: var(--accent);
}

button.ghost, .text-btn {
  color: var(--text);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}

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

.cookies {
  margin-top: 16px;
  color: var(--muted);
}

.cookies summary { cursor: pointer; }

.cookies label {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.hint, .footnote, .empty, .meta, .progress-text, .file-name {
  color: var(--muted);
  line-height: 1.4;
}

.hint { margin: 8px 0 0; font-size: 13px; }

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

.preview {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(27, 30, 22, 0.92);
  box-shadow: var(--shadow);
}

.preview:not(:has(img)) {
  grid-template-columns: 1fr;
}

.thumb {
  width: 100%;
  height: 148px;
  object-fit: cover;
  border-radius: 14px;
  background: #0e100c;
}

.preview h2, .job h3 {
  margin: 0;
  min-width: 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.meta { margin: 8px 0 0; font-size: 14px; }

.qualities {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.qualities label {
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}

.qualities label { position: relative; }

.qualities input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.qualities label:has(input:checked) {
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: none;
}

.qualities label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.card-actions { margin-top: 16px; }

h2 { margin: 0; font-size: 20px; }

.library { margin-top: 36px; }

#history {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.job {
  min-width: 0;
  max-width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-raised);
}

.job-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  min-width: 0;
}

.job-top h3 {
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.phase {
  flex: 0 0 auto;
  color: var(--ok);
  font-size: 13px;
  font-weight: 700;
}

.job.error-job .phase { color: var(--danger); }

.progress {
  height: 6px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #2a2e24;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
}

.progress.indeterminate span {
  width: 40%;
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  from { transform: translateX(-120%); }
  to { transform: translateX(280%); }
}

.progress-text { margin: 8px 0 0; font-size: 13px; }

.files { display: grid; gap: 10px; margin-top: 12px; min-width: 0; }

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: start;
  gap: 8px;
  min-width: 0;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.job-error { margin: 8px 0 0; color: var(--danger); font-size: 14px; }

.footnote { margin: 28px 0 0; font-size: 13px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  main { width: min(100% - 24px, 880px); padding-top: 28px; }
  h1 { font-size: 34px; }
  .preview, .form-row, .job-top { grid-template-columns: 1fr; display: grid; }
  .file-actions { width: 100%; }
  .text-btn, #download, button[type="submit"] { text-align: center; }
}
