:root {
  --bg: #1b2140;
  --bg-deep: #12162c;
  --card: #232a4d;
  --text: #f3ecd8;
  --text-soft: #c9c2a8;
  --gold: #d4a94c;
  --gold-deep: #a67f2e;
  --line: #34406e;
  --shadow: 0 18px 40px -20px rgba(10, 12, 25, 0.6);
  --radius: 10px;
  --on-gold: #1b2140;
  --gold-button: #d4a94c;
  --parchment-text: #2b1d0f;
  --parchment-line: #8a6a2f;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3ecd8;
    --bg-deep: #e8dfc2;
    --card: #ffffff;
    --text: #1b2140;
    --text-soft: #4a5178;
    --gold: #a67f2e;
    --gold-deep: #7a5c1e;
    --line: #e3dcc4;
    --shadow: 0 18px 40px -20px rgba(60, 50, 20, 0.2);
    --gold-button: #b28c3d;
  }
}
:root[data-theme="light"] {
  --bg: #f3ecd8; --bg-deep: #e8dfc2; --card: #ffffff; --text: #1b2140;
  --text-soft: #4a5178; --gold: #a67f2e; --gold-deep: #7a5c1e;
  --line: #e3dcc4; --shadow: 0 18px 40px -20px rgba(60, 50, 20, 0.2);
  --gold-button: #b28c3d;
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--line) var(--bg-deep); scrollbar-width: thin; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, sans-serif; font-size: 19px; line-height: 1.6;
}
::selection { background: var(--gold); color: var(--bg-deep); }
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 3px solid var(--bg-deep); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-deep); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; line-height: 1.15; color: var(--text); margin: 0 0 0.6em; }
p { margin: 0 0 1em; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 1.5rem; }
.wrap-wide { max-width: 980px; margin: 0 auto; padding: 0 1.5rem; }
.site-header {
  padding: 1.5rem 0 1.25rem; position: relative;
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(to right, transparent, var(--gold-deep) 20%, var(--gold) 50%, var(--gold-deep) 80%, transparent) 1;
}
.ornament {
  position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 8px; height: 8px; background: var(--bg-deep); border: 1px solid var(--gold);
}
.brand { font-family: "Fraunces", serif; font-weight: 600; color: var(--gold); font-size: 1.3rem; }

.hero { position: relative; padding: 4rem 0 3rem; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; top: -60px; left: 0; right: 0; height: 420px;
  background: url('../img/parchment-b.jpg') center/cover;
  mix-blend-mode: luminosity; opacity: 0.22; pointer-events: none;
  mask-image: linear-gradient(to bottom, black 0%, black 55%, transparent 95%);
}
.branch-corner {
  position: absolute; top: -10px; right: -10px; width: 200px; height: 200px;
  background: url('../img/branch-accent.jpg') center/cover; mix-blend-mode: screen;
  opacity: 0.85; pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(2rem, 1.1rem + 3.6vw, 3.1rem); max-width: 18ch; letter-spacing: -0.01em; }
.ai-tag { color: var(--gold-deep); font-style: italic; font-size: 0.95rem; margin-bottom: 0.9em; }
.lede { color: var(--text-soft); font-size: 1.05rem; max-width: 58ch; }

form {
  position: relative; color: var(--parchment-text); padding: 2.25rem 1.75rem 1.75rem;
  background: url('../img/parchment-a.jpg') center/cover, #d8c49c;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.55);
  clip-path: polygon(
    0% 2%, 3% 0%, 12% 1.5%, 22% 0.3%, 34% 1.8%, 47% 0.2%, 58% 1.4%, 71% 0%, 83% 1.6%, 94% 0.4%, 100% 2%,
    100% 97%, 96% 100%, 87% 98.2%, 76% 99.6%, 63% 98%, 51% 99.7%, 39% 98.3%, 27% 100%, 16% 98.5%, 5% 99.8%, 0% 97%
  );
}
form::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  clip-path: inherit; background: rgba(255,248,232,0.55);
}
form::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  clip-path: inherit; border: 1px solid var(--parchment-line); opacity: 0.7;
}
form > * { position: relative; z-index: 1; }
label { display: block; font-weight: 600; margin-bottom: 0.4em; color: var(--parchment-text); }
input[type="text"], textarea {
  width: 100%; padding: 0.7rem; border: 1px solid var(--parchment-line); border-radius: 3px;
  background: rgba(255,251,240,0.75); color: var(--parchment-text); font-size: 1rem;
  margin-bottom: 1.25rem; font-family: inherit;
}
input[type="text"]::placeholder, textarea::placeholder { color: #6b5738; }
.verse-picks-wrap { margin: -0.5rem 0 1rem; }
.verse-picks-label { display: block; font-size: 0.8rem; color: var(--parchment-text); opacity: 0.75; margin-bottom: 0.35rem; }
.verse-picks {
  display: flex; gap: 0.4rem; overflow-x: auto; overflow-y: hidden; padding-bottom: 0.3rem;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.verse-pick {
  flex: 0 0 auto; white-space: nowrap;
  background: rgba(255,251,240,0.6); color: var(--parchment-text); border: 1px solid var(--parchment-line);
  border-radius: 999px; padding: 0.25rem 0.7rem; font-size: 0.8rem; font-weight: 400; cursor: pointer;
}
.verse-pick:hover { background: rgba(255,251,240,0.95); }
.style-toggle { border: none; padding: 0; margin: 0 0 1.25rem; }
.style-toggle label { display: inline-block; font-weight: 400; margin-right: 1.5rem; color: var(--parchment-text); }
.style-toggle input[type="radio"] { accent-color: var(--parchment-line); }
button {
  background: var(--gold-button); color: var(--on-gold); border: none; padding: 0.85rem 1.5rem;
  border-radius: 7px; font-weight: 600; font-size: 1.05rem; cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: not-allowed; }
.status { color: var(--parchment-text); margin-top: 1rem; }

.brush-loader { display: none; text-align: center; padding: 0.5rem 0; }
.brush-loader.active { display: block; }
.brush-loader svg { width: 100%; max-width: 260px; height: 44px; overflow: visible; }
.brush-track { fill: none; stroke: rgba(43,29,15,0.18); stroke-width: 3; stroke-linecap: round; }
.brush-stroke {
  fill: none; stroke: var(--parchment-line); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 340; stroke-dashoffset: 340;
  animation: brush-draw 2.2s ease-in-out infinite;
}
.brush-tip {
  offset-path: path('M10,25 Q45,8 90,25 T170,25 T250,25 T310,25');
  animation: brush-move 2.2s ease-in-out infinite;
}
.brush-tip circle { fill: #b8935a; }
@keyframes brush-draw {
  0% { stroke-dashoffset: 340; opacity: 1; }
  55% { stroke-dashoffset: 0; opacity: 1; }
  75% { stroke-dashoffset: 0; opacity: 0; }
  76% { stroke-dashoffset: 340; opacity: 0; }
  100% { stroke-dashoffset: 340; opacity: 1; }
}
@keyframes brush-move {
  0% { offset-distance: 0%; opacity: 1; }
  55% { offset-distance: 100%; opacity: 1; }
  75% { offset-distance: 100%; opacity: 0; }
  76% { offset-distance: 0%; opacity: 0; }
  100% { offset-distance: 0%; opacity: 1; }
}

.examples { padding: 1.5rem 0 3.5rem; }
.examples-heading { text-align: center; font-size: 1.4rem; margin: 0 0 2rem; }
.examples-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; max-width: 500px; margin: 0 auto; }
.examples-grid figure {
  position: relative; margin: 0; padding: 7px; border: 1px solid var(--parchment-line);
  background: url('../img/parchment-a.jpg') center/cover;
}
.examples-grid img {
  width: 100%; aspect-ratio: 7 / 9; object-fit: cover; display: block;
  border-radius: 2px; box-shadow: var(--shadow); position: relative; z-index: 1;
}
.examples-grid figure::before {
  content: ""; position: absolute; top: -10px; right: -10px; width: 38px; height: 38px;
  background: url('../img/branch-accent.jpg') center/cover; mix-blend-mode: screen;
  opacity: 0.9; pointer-events: none; z-index: 2;
}
.examples-grid figcaption {
  position: relative; z-index: 1; margin-top: 0.6rem; text-align: center;
}
.examples-grid figcaption span {
  display: inline-block; background: rgba(255,251,240,0.85); color: var(--parchment-text);
  padding: 0.2rem 0.7rem; border-radius: 3px; font-family: "Fraunces", serif;
  font-weight: 600; letter-spacing: 0.02em;
}
@media (max-width: 620px) {
  .examples-grid { grid-template-columns: repeat(2, 1fr); max-width: 300px; gap: 0.85rem; }
}

#previewModal {
  border: none; border-radius: var(--radius); background: var(--card); color: var(--text);
  padding: 1.75rem; max-width: min(90vw, 480px); box-shadow: var(--shadow); text-align: center;
  position: fixed; margin: auto; inset: 0;
}
#previewModal::backdrop { background: rgba(10, 12, 25, 0.65); }
#previewModal[open] { display: block; }
#previewCloseBtn {
  position: absolute; top: 0.6rem; right: 0.75rem; background: none; border: none;
  color: var(--text-soft); font-size: 1.6rem; line-height: 1; padding: 0.25rem 0.5rem; cursor: pointer;
}
#previewModal img { max-width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); }
.hint { color: var(--text-soft); font-size: 0.9rem; }
footer {
  position: relative; padding: 3rem 1.5rem 4rem; color: var(--text-soft);
  font-size: 0.85rem; text-align: center;
  border-top: 1px solid transparent;
  border-image: linear-gradient(to right, transparent, var(--gold-deep) 20%, var(--gold) 50%, var(--gold-deep) 80%, transparent) 1;
}
footer .ornament { top: -5px; bottom: auto; }

@media (max-width: 480px) {
  .site-header { padding: 0.6rem 0; }
  .hero { padding: 1rem 0 1rem; }
  .hero h1 { font-size: 1.75rem; margin-bottom: 0.35em; }
  .ai-tag { font-size: 0.85rem; margin-bottom: 0.5em; }
  .lede { font-size: 0.87rem; line-height: 1.35; margin-bottom: 0.6em; }
  form { padding: 1rem; }
  label, legend { line-height: 1.2; margin-bottom: 0.25em; }
  input[type="text"], textarea { padding: 0.5rem; margin-bottom: 0.6em; }
  textarea { min-height: 2.6em; }
  .style-toggle { margin-bottom: 0.6em; }
  button { padding: 0.6rem 1.2rem; font-size: 0.95rem; }
  .verse-picks-wrap { margin: -0.35rem 0 0.5em; }
  .verse-picks { gap: 0.25rem; }
  .verse-picks-label { display: none; }
  .verse-pick { padding: 0.15rem 0.5rem; font-size: 0.7rem; }
}
