:root {
  --bg: #0e0e10;
  --fg: #e8e8ea;
  --dim: #7a7a82;
  --line: #26262b;
  --accent: #c9a6ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* room for the scrollbar even when the page is short: the "big resolution" grid toggles the
   page between fitting the window and not, and the centered layout would shift by its width */
html { scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#status {
  margin: 0 0 0 auto;
  color: var(--dim);
  font-size: 13px;
  text-align: right;
}

.lang { display: flex; gap: 2px; flex: none; }

.lang button {
  font: inherit;
  font-size: 12px;
  color: var(--dim);
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 1px 6px;
  cursor: pointer;
}

.lang button:hover { color: var(--fg); }

.lang button[aria-pressed="true"] { color: var(--accent); border-color: var(--line); }

.drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 140px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--dim);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop:hover, .drop.over {
  border-color: var(--accent);
  background: #15131a;
}

#hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

#hint svg { color: var(--accent); opacity: 0.85; }

.drop:hover #hint svg, .drop.over #hint svg { opacity: 1; }

.drop img {
  max-height: 220px;
  max-width: 60%;
  border-radius: 8px;
}

.option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--dim);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.option input { accent-color: var(--accent); margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.grid[hidden] { display: none; }

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #121215;
}

/* fixed-height frame: a tall photo does not make a card a screen long */
.card .frame {
  position: relative;
  aspect-ratio: clamp(0.75, var(--ar, 1), 1.78);
  background: #0b0b0d;
  overflow: hidden;
}

.card .view {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

.card .view[hidden] { display: none; }

/* placeholder until the first intermediate image: a pulsing glow. Only opacity is animated,
   which the compositor does without repainting: repaints would take the phone GPU from the network */
.card.pending:not(.previewed) .frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 35%, #c9a6ff33, transparent 50%),
    radial-gradient(circle at 70% 65%, #6fd3ff26, transparent 50%);
  animation: pulse 2s ease-in-out infinite alternate;
  will-change: opacity;
}

/* intermediate images: smaller than the result, slightly dimmed until it is done */
.card.pending .view { opacity: 0.75; cursor: default; }

@keyframes pulse { from { opacity: 0.35; } to { opacity: 1; } }

.card .bar {
  height: 2px;
  background: var(--accent);
  width: 0;
  transition: width 0.2s;
}

.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
}

.card .meta span { color: var(--dim); }

.card a {
  color: var(--accent);
  text-decoration: none;
}

.card a[hidden], .card button[hidden] { display: none; }

.card button {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 2px 10px;
  cursor: pointer;
}

#viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: #000000e6;
  cursor: zoom-out;
}

#viewer[hidden] { display: none; }

#viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

footer {
  margin-top: 32px;
  color: var(--dim);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 640px) {
  main { padding-top: 24px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card .meta { padding: 6px 8px; font-size: 12px; gap: 2px 8px; }
  #status { font-size: 12px; }
  #hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

#hint svg { color: var(--accent); opacity: 0.85; }

.drop:hover #hint svg, .drop.over #hint svg { opacity: 1; }

.drop img { max-height: 160px; }
}
