:root {
  --ink: #1a1714;
  --paper: #faf8f4;
  --muted: #6b635a;
  --line: #ddd6cb;
  --accent: #7a4a2b;
  --accent-ink: #fff;
  --error: #9b2c22;
  --radius: 12px;
  --gap: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece7e0;
    --paper: #16140f;
    --muted: #9d948a;
    --line: #35302a;
    --accent: #c98a5e;
    --accent-ink: #1a1714;
    --error: #e08076;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom);
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: calc(env(safe-area-inset-top) + 0.75rem) 1rem 0.75rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 2;
}

.bar h1 {
  font-size: 1.1rem;
  margin: 0;
  letter-spacing: 0.02em;
}

main {
  max-width: 42rem;
  margin: 0 auto;
  padding: var(--gap);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: var(--gap);
}

.card h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
}

.row h2 {
  margin-bottom: 0;
}

.hint {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  /* 16px keeps iOS Safari from zooming in when the field takes focus. */
  font-size: 16px;
  padding: 0.7rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

input:focus-visible,
button:focus-visible,
.as-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary,
.as-button {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0.8rem 1rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.primary:disabled {
  opacity: 0.45;
  cursor: default;
}

.link {
  background: none;
  border: 0;
  padding: 0.5rem 0;
  color: var(--accent);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: underline;
}

.error {
  color: var(--error);
  font-size: 0.875rem;
  margin: 0.75rem 0 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
}

/* Thumbnails ------------------------------------------------------------------------ */

.thumbs {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.75rem;
}

.thumb {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
}

.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.thumb-number {
  position: absolute;
  top: 0.375rem;
  left: 0.375rem;
  min-width: 1.5rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.65);
  color: #fff;
  font-size: 0.8125rem;
  text-align: center;
}

.thumb-controls {
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.thumb-controls button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: none;
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
}

.thumb-controls button:last-child {
  border-right: 0;
}

.thumb-controls button:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Progress -------------------------------------------------------------------------- */

.progress {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  height: 100%;
  width: 0;
  background-color: var(--accent);
  transition: width 0.4s ease;
}

/* A model call takes half a minute or so, during which the width cannot honestly change.
   The sheen says "still working" without inventing progress that hasn't happened. */
.progress-fill.working {
  background-image: linear-gradient(
    100deg,
    transparent 35%,
    rgb(255 255 255 / 0.35) 50%,
    transparent 65%
  );
  background-size: 250% 100%;
  animation: sheen 1.8s linear infinite;
}

@keyframes sheen {
  from {
    background-position: 250% 0;
  }
  to {
    background-position: -150% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill.working {
    animation: none;
  }
}

.statuses {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9375rem;
}

.statuses li {
  display: flex;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.statuses li:last-child {
  border-bottom: 0;
}

.status-value {
  color: var(--muted);
}

.statuses li[data-status="done"] .status-value {
  color: var(--accent);
}

.statuses li[data-status="failed"] .status-value,
.statuses li[data-status="unreadable"] .status-value {
  color: var(--error);
}
