:root {
  --bg: #f4f0e8;
  --ink: #1c1914;
  --muted: #6b6459;
  --line: #d8d0c4;
  --accent: #9c2c16;
  --card: #fffdf8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.25rem 2rem;
}

footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

footer a {
  color: var(--accent);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0 0 0.4rem;
}

h1 {
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 0.6rem;
}

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

.lede,
.hint {
  color: var(--muted);
  line-height: 1.5;
}

#wait-help {
  margin: -0.35rem 0 0.9rem;
  min-height: 2.6em;
}

form,
#progress,
#result {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 1.25rem;
  margin-top: 1.5rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

input,
select,
button {
  font: inherit;
  color: var(--ink);
}

input,
select {
  background: #fff;
  border: 1px solid var(--line);
  padding: 0.55rem 0.65rem;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

button {
  background: var(--ink);
  color: var(--bg);
  border: 0;
  padding: 0.7rem 1.1rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.error {
  color: var(--accent);
  margin-top: 0.8rem;
}

#log {
  background: #1c1914;
  color: #efe8db;
  padding: 0.9rem;
  min-height: 8rem;
  max-height: 16rem;
  overflow: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

#gif-preview {
  width: 100%;
  border: 1px solid var(--line);
  background: #111;
  cursor: zoom-in;
}

.gif-wrap {
  position: relative;
}

.gif-wrap.busy #gif-preview {
  opacity: 0.45;
}

#gif-busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  background: rgba(28, 25, 20, 0.45);
  color: #fffdf8;
  font-size: 1.05rem;
}

#gif-busy[hidden] {
  display: none;
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
}

.downloads a {
  color: var(--accent);
}

.downloads button {
  background: transparent;
  color: var(--accent);
  padding: 0;
  text-decoration: underline;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem;
  max-height: 28rem;
  overflow: auto;
}

.thumb {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  padding: 0.35rem;
  background: #fff;
}

.thumb.dropped {
  opacity: 0.45;
}

.thumb button {
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: zoom-in;
}

.keep-toggle {
  flex-direction: row;
  align-items: center;
  margin: 0 0 0.3rem;
  font-size: 0.72rem;
}

.thumb img {
  width: 100%;
  display: block;
}

.thumb span {
  display: block;
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--muted);
  margin-top: 0.3rem;
}

.thumbs.locked .thumb input {
  pointer-events: none;
}

.pace {
  margin-top: 0.8rem;
  max-width: 10rem;
}

.rebuild-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(16, 14, 10, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
}

#lightbox[hidden] {
  display: none;
}

#lightbox figure {
  margin: 0;
  max-width: min(92vw, 1100px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

#lb-image {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  background: #111;
}

#lightbox figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: #efe8db;
  font-size: 0.95rem;
}

#lb-keep-wrap {
  flex-direction: row;
  align-items: center;
  margin: 0;
  color: #efe8db;
}

#lightbox.gif-mode #lb-keep-wrap,
#lightbox.gif-mode .lb-nav {
  display: none !important;
}

.privacy {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.privacy summary {
  cursor: pointer;
  color: var(--ink);
}

.privacy p {
  margin: 0.7rem 0 0;
}

.lb-nav,
#lb-close {
  background: #efe8db;
  color: #1c1914;
}

.lb-nav {
  width: 3rem;
  height: 3rem;
  font-size: 1.8rem;
  line-height: 1;
}

@media (max-width: 720px) {
  .row,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .lb-nav {
    display: none;
  }
}
