:root {
  --bg: #0b1428; --bg2: #03050a; --card: #111c33; --ink: #f1efe9; --muted: #9aa4b8; --accent: #ffb347; --accent-ink: #1a1206; --line: #24304a;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg2); }
body { margin: 0; min-height: 100vh; background: linear-gradient(180deg, var(--bg) 0, var(--bg2) 1400px) var(--bg2); color: var(--ink); font: 17px/1.5 var(--sans); }
a { color: var(--accent); }
.small { font-size: 14px; color: var(--muted); }
.center { text-align: center; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; max-width: 1120px; margin: 0 auto; }
.brand { font: 700 22px var(--serif); color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent); font-style: italic; }
.top select { font: inherit; font-size: 14px; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
main { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.hero { text-align: center; padding: 28px 0 24px; max-width: 760px; margin: 0 auto; }
.hero h1 { font: 700 clamp(32px, 6vw, 56px)/1.08 var(--serif); margin: 0 0 14px; }
.hero h1 em { color: var(--accent); }
.lead { font-size: 18px; color: var(--muted); margin: 0; }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; padding: 10px 0 40px; }
@media (max-width: 820px) { .editor { grid-template-columns: 1fr; } }
.preview-wrap { position: sticky; top: 12px; }
@media (max-width: 820px) { .preview-wrap { position: static; } }
.preview { aspect-ratio: 210 / 297; background: #000; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; display: grid; place-items: center; box-shadow: 0 16px 40px rgba(0,0,0,.4); transition: opacity .2s; padding: 0; }
.preview p { padding: 20px; text-align: center; }
.preview.loading { opacity: .6; }
.preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.controls fieldset { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px 16px 16px; margin: 0 0 14px; }
.controls legend { font-weight: 700; padding: 0 6px; }
.controls label { display: block; margin: 8px 0; font-size: 15px; }
.controls input:not([type=radio]):not([type=checkbox]), .controls select, .controls textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #0a1222; color: var(--ink); margin-top: 4px; color-scheme: dark; }
.controls textarea { resize: vertical; }
#story { font: italic 16px/1.45 var(--serif); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row.tight { align-items: center; }
.row.tight .btn { flex: none; margin-top: 4px; white-space: nowrap; }
.sub { margin: 10px 0 4px; font-weight: 600; font-size: 15px; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.choices label { margin: 0; }
.choices input { position: absolute; opacity: 0; }
.choices span { display: inline-flex; gap: 8px; align-items: center; padding: 8px 13px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; background: #0a1222; }
.choices i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid #889; display: inline-block; }
.choices b { font-weight: 500; }
.choices input:checked + span { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.check { display: flex !important; gap: 10px; align-items: flex-start; }
.check input { margin-top: 3px; width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.avail { margin-top: 10px; background: #0a1222; border-radius: 10px; padding: 8px 12px; }
.avail ul { list-style: none; padding: 0; margin: 4px 0; font-size: 14px; }
.avail li { padding: 3px 0; }
.avail li.no { color: var(--muted); }
.formats { display: grid; gap: 8px; margin: 4px 0 8px; }
.formats input { position: absolute; opacity: 0; }
.formats span { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; background: #0a1222; }
.formats input:checked + span { border: 2px solid var(--accent); }
.btn { display: inline-block; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font: 700 16px var(--sans); padding: 12px 18px; cursor: pointer; text-align: center; text-decoration: none; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-big { font-size: 18px; padding: 15px 24px; width: 100%; margin-top: 8px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.error { color: #ff7b7b; font-weight: 600; min-height: 1em; }
.foot { text-align: center; padding: 30px 16px; font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); }
.page { max-width: 760px; margin: 0 auto; padding: 20px 16px 60px; }
.done { text-align: center; padding: 60px 16px; }
.done .links { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 20px 0; }
.done .btn-big { width: auto; }

/* Loader while NASA images are fetched and the card is drawn */
.preview-box { position: relative; }
.loader { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(5, 8, 16, .55); color: #fff; font-size: 15px; border-radius: 6px; backdrop-filter: blur(2px); }
.loader[hidden] { display: none; }
.spin { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,255,255,.25); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }
.btn.busy { opacity: .75; pointer-events: none; }
.btn.busy::before { content: ''; display: inline-block; width: 16px; height: 16px; margin-right: 10px; vertical-align: -2px; border-radius: 50%; border: 3px solid rgba(0,0,0,.25); border-top-color: currentColor; animation: spin 0.9s linear infinite; }

/* Printed orders: copies + "do we deliver to you?" */
#ship { margin: 8px 0 4px; }
.ship-row { display: flex; gap: 10px; flex-wrap: wrap; }
.ship-row label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; margin: 0; }
.ship-row select { padding: 7px 8px; border-radius: 8px; border: 1px solid #ccc; font: inherit; background: #fff; color: #222; }
.ship-msg { margin: 8px 0 4px; }
.ship-no { color: #b00; }
.ship-contact a, .ship-msg a { color: inherit; }

.kinds { margin: 0 0 10px; }
[hidden] { display: none !important; }
#pack-count { font-weight: 700; margin: 6px 0 2px; }
