@font-face {
  font-family: "Instrument Serif";
  src: url("/static/assets/instrument-serif.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ground: #191218;
  --panel: #231a22;
  --ink: #fff5e8;
  --muted: #d2b9c6;
  --line: #634957;
  --field-line: #8d6a7b;
  --accent: #ffbf70;
  --accent-hover: #ffd295;
  --display: "Instrument Serif", Georgia, serif;
  --body: "Segoe UI", system-ui, sans-serif;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
::selection { background: var(--accent); color: var(--ground); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
body { margin: 0; }
button, textarea { font: inherit; }
button { cursor: pointer; }

.page {
  width: min(100% - 112px, 1120px);
  margin-inline: auto;
}

.opening {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(36px, 7vw, 100px);
  align-items: center;
  min-height: min(820px, 100svh);
  padding-block: 56px;
}

.opening:has(.result:not([hidden])) { align-items: start; }

h1, h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -.038em;
}

h1 {
  margin-bottom: 32px;
  font-size: clamp(4rem, 7.5vw, 6rem);
  line-height: .99;
}

h1 span { color: var(--accent); }

.question {
  display: grid;
  border: 1px solid var(--field-line);
  border-radius: 16px;
  background: var(--panel);
}

.question:focus-within { border-color: var(--accent); }

textarea {
  display: block;
  width: 100%;
  min-height: 109px;
  padding: 21px 22px 12px;
  resize: vertical;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--ink);
  caret-color: var(--accent);
  font-size: clamp(1rem, 1.6vw, 1.125rem);
  line-height: 1.5;
}

textarea:focus-visible { outline: 0; }
textarea::placeholder { color: var(--muted); opacity: 1; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding: 7px 12px 12px;
}

.submit {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  gap: 14px;
  padding-inline: 17px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #261319;
  font-weight: 700;
}

.submit:hover { background: var(--accent-hover); }
.submit:disabled { cursor: wait; opacity: .77; }
.submit:disabled .arrow { display: none; }

.arrow {
  position: relative;
  width: 13px;
  height: 1.5px;
  background: currentColor;
}

.arrow::after {
  position: absolute;
  top: -3.5px;
  right: 0;
  width: 8px;
  height: 8px;
  border-top: 1.5px solid;
  border-right: 1.5px solid;
  content: "";
  transform: rotate(45deg);
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.examples button {
  min-height: 40px;
  padding-inline: 13px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
}

.examples button:hover { border-color: var(--accent); color: var(--ink); }
.status { margin: 14px 0 0; color: var(--accent); line-height: 1.5; }

.gallery { min-width: 0; margin: 0; }

.portrait {
  display: grid;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1 / 1;
  place-items: center;
  border: 1px solid #382833;
  border-radius: 16px;
  background: #000;
}

.portrait:has(.daylight) { background: #fff; }

.portrait img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  object-fit: contain;
}

.portrait .daylight { transform: scale(1.24); }

.thumbnails {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-top: 10px;
}

.thumbnails button {
  display: grid;
  overflow: hidden;
  height: clamp(47px, 6vw, 70px);
  min-width: 0;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.thumbnails button:first-child { background: #000; }
.thumbnails button:hover { border-color: var(--accent); }
.thumbnails button[aria-pressed="true"] { border: 2px solid var(--accent); }

.thumbnails img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}

.thumbnails button:first-child img { object-fit: contain; }

.portrait .entering { animation: appear 380ms cubic-bezier(.16, 1, .3, 1); }
@keyframes appear { from { opacity: .25; } to { opacity: 1; } }

.result {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.result h2 {
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  scroll-margin-top: 24px;
}
.answer { line-height: 1.7; }
.answer a { color: var(--accent); text-underline-offset: .2em; }
.answer pre { padding: 1em; overflow: auto; background: var(--panel); }
.answer hr { border: 0; border-top: 1px solid var(--line); }

@media (max-width: 880px) {
  .page { width: calc(100% - 64px); }
  h1 { font-size: clamp(3.5rem, 8.5vw, 5.25rem); }
}

@media (max-width: 660px) {
  .page { width: min(100% - 40px, 475px); }
  .opening {
    grid-template-columns: minmax(0, 1fr);
    gap: 30px;
    min-height: 0;
    padding-block: 44px 38px;
  }
  h1 { margin-bottom: 22px; font-size: clamp(3.25rem, 12vw, 4.75rem); }
  .portrait { aspect-ratio: 1.42 / 1; }
  .portrait img { object-position: center; }
  .portrait .daylight { transform: scale(1.16); }
  .thumbnails button { height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  .portrait .entering { animation: none; }
}
