/* Conjure — a quiet grey room with one white card; the picture takes the whole screen.
   Layout: centered stack (logo, card, note) on a light grey ground; result view is full-bleed. */
:root {
  --ground: #e9e9e7;   /* page */
  --card: #ffffff;     /* writing card */
  --ink: #111111;      /* text, button, logo */
  --hint: #a9a9a6;     /* placeholder, note */
  --edge: #dcdcd9;     /* card hairline */
  --focus: #111111;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* writing screen: a generated picture behind one sharp white card */
.backdrop {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.backdrop.ready { opacity: 1; }
.write {
  position: relative;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding-inline: 16px;
  padding-block: 40px;
}
.card {
  width: min(600px, 100%);
  background: var(--card);
  border-radius: 0;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.06);
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.card-head { padding: 18px 24px; background-color: #111; transition: background-color 1.2s ease; }
.card-head.textured { background-size: 100% 100%; image-rendering: pixelated; }
.logo { filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.25)); }
.logo { width: 132px; height: auto; color: #fff; display: block; }
.poem {
  width: 100%;
  min-height: clamp(220px, 36vh, 360px);
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: 400 17px/1.65 var(--sans);
  letter-spacing: -0.005em;
  padding: 20px 24px;
}
.poem::placeholder { color: var(--hint); }
.card:focus-within { box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.14); }

.card-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--edge);
}
.note {
  margin: 0;
  padding: 14px 24px;
  align-self: center;
  color: var(--hint);
  font-size: 12px;
  line-height: 1.45;
}
.submit {
  appearance: none;
  border: 0;
  border-radius: 0;
  width: 100%;
  min-height: 64px;
  background: var(--ink);
  color: #fff;
  font: 600 15px/1 var(--sans);
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color .15s;
}
.submit:hover:not(:disabled) { background: #2a2a2a; }
.submit:disabled { background: #d9d9d6; color: #fff; cursor: default; }
.submit:focus-visible { outline: 2px solid #fff; outline-offset: -6px; }
.pill:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* result screen */
.view { position: fixed; inset: 0; background: #000; }
.art {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.bar {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px max(16px, 2.5vw) calc(16px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}
.pill {
  pointer-events: auto;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  font: 500 14px/1 var(--sans);
  cursor: pointer;
  box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background-color .15s, transform .1s;
}
.pill:hover { background: #fff; }
.pill:active { transform: translateY(1px); }
.pill svg { width: 16px; height: 16px; }
.pill-dark { background: rgba(17, 17, 17, 0.9); color: #fff; }
.pill-dark:hover { background: #111; }
.seg {
  pointer-events: auto;
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  height: 44px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.seg-btn {
  appearance: none;
  border: 0;
  border-radius: 0;
  padding: 0 14px;
  background: transparent;
  color: #555;
  font: 500 13px/1 var(--sans);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.seg-btn[aria-pressed="true"] { background: #111; color: #fff; }
.seg-btn:focus-visible { outline: 2px solid #111; outline-offset: 2px; }
@media (max-width: 520px) {
  .bar { flex-wrap: wrap; }
  .seg { order: -1; width: 100%; justify-content: center; }
  .seg-btn { flex: 1; }
}
.toast {
  position: absolute; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  margin: 0; padding: 8px 14px; border-radius: 999px;
  background: rgba(17, 17, 17, 0.85); color: #fff; font-size: 13px;
  opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
