/* ---------- Editor (screen only) ---------- */

:root {
  --ink: #1d1a16;
  --muted: #5d564c;
  --paper: #f6f2ea;
  --card: #ffffff;
  --line: #d9d1c3;
  --accent: #6e2b1f;
  --warn-bg: #fff4d6;
  --warn: #7a5200;
  --error-bg: #fde4e1;
  --error: #9b1c12;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 18px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.toolbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.toolbar h1 { margin: 0; font-size: 1.15rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.status { flex-basis: 100%; margin: 0; min-height: 1.2em; font-size: 0.9rem; color: var(--muted); }

button, .button {
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button:focus-visible, .button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
  grid-template-areas: "picker picker" "editor preview";
  gap: 16px;
  padding: 16px;
  align-items: start;
}
.picker { grid-area: picker; }
.editor { grid-area: editor; }
.preview { grid-area: preview; position: sticky; top: 16px; }

/* Phone: picker, then preview, then the wording. Printing is the main job there. */
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "picker" "preview" "editor"; }
  .preview { position: static; }
}

.picker h2 { font-size: 1rem; margin: 0 0 8px; }
.designs { display: grid; grid-template-columns: repeat(4, minmax(0, 112px)); gap: 10px; }
.design {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font-size: 0.85rem;
  line-height: 1.2;
  text-align: center;
}
.design img { width: 100%; height: auto; aspect-ratio: 240 / 311; border: 1px solid var(--line); }
.design[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); font-weight: 600; }

.pages { display: flex; flex-wrap: wrap; gap: 16px; }
.sheet-frame {
  /* Width/height set by app.js to the scaled page size. */
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.hint { margin: 0 0 12px; color: var(--muted); font-size: 0.9rem; }
.editor fieldset {
  min-width: 0; /* fieldsets default to their content's width, which breaks narrow screens */
  margin: 0 0 16px;
  padding: 12px 14px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.editor legend { font-weight: 700; padding: 0 6px; }
.field { margin: 0 0 12px; }
.field > label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.field input, .field textarea {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
}
.field textarea { resize: vertical; }
.field .help { margin: 4px 0 0; font-size: 0.82rem; color: var(--muted); }
.day-row { display: grid; grid-template-columns: 2.4em 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
.day-row label { font-weight: 700; text-align: right; }
.fit-note { grid-column: 2; margin: -2px 0 4px; font-size: 0.82rem; padding: 2px 8px; border-radius: 4px; }
.fit-note.small { background: var(--warn-bg); color: var(--warn); }
.fit-note.overflow { background: var(--error-bg); color: var(--error); }
.fit-note:empty { display: none; }
.field .fit-note { display: block; margin-top: 4px; }

/* ---------- Flyer pages (screen and print) ---------- */

.sheet {
  position: relative;
  width: 8.5in;
  height: 11in;
  overflow: hidden;
  background: #fff;
  color: #000;
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  transform-origin: top left;
}
.sheet .art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.fit {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
  /* Words are never split: a long word shrinks the text instead, so the
     result is the same in every browser. */
  hyphens: manual;
  -webkit-hyphens: manual;
  overflow-wrap: normal;
}
.fit > .inner { width: 100%; }
.fit.left { text-align: left; justify-content: flex-start; }
.fit p, .fit h2, .fit h3, .fit h4, .fit ol, .fit ul { margin: 0; }

/* Shows on screen only, to point at text that doesn't fit. */
.fit.is-overflow { outline: 2px dashed #d0021b; outline-offset: 1px; }

/* Front */
.headline { font-size: 1.85em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; line-height: 1.05; text-wrap: balance; }
.subtitle { font-size: 0.8em; font-style: italic; letter-spacing: 0.04em; margin-top: 0.3em !important; }
.scripture { font-size: 1em; font-style: italic; font-weight: 600; margin-top: 0.35em !important; }
.footer-verse { font-style: italic; }
.zone > .inner > * + .footer-verse { margin-top: 0.3em; }

.slot .num { font-weight: 700; font-size: 1.25em; line-height: 1; }
.slot.block .num { display: block; margin-bottom: 0.15em; }
.slot.inline .num { margin-right: 0.25em; }
.slot .spare { font-size: 1.6em; }
.slot.backed { background: #fff; }

/* Back */
.back-heading { font-size: 1.6em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.1; text-wrap: balance; }
.intro { margin-top: 0.4em !important; text-align: justify; text-align-last: center; }
.note { margin-top: 0.4em !important; font-style: italic; font-weight: 600; }
.panel-title {
  font-size: 1.2em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  border-bottom: 1px solid #000;
  padding-bottom: 0.2em;
  margin-bottom: 0.4em !important;
}
.top10 { padding-left: 1.6em; font-size: 1.15em; font-weight: 600; line-height: 1.35; }
.small-note { margin-top: 0.6em !important; font-size: 0.85em; font-style: italic; }
.groups { column-count: 2; column-gap: 1em; }
.group { break-inside: avoid; margin-bottom: 0.45em; }
.group h4 { font-size: 0.9em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.group ul { padding-left: 1em; line-height: 1.2; }
.drop h4 { font-size: 1em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.2em; }
.drop .line:first-of-type { font-weight: 700; }
.back-footer { font-style: italic; letter-spacing: 0.03em; }
.on-rule .back-footer { display: inline; background: #fff; padding: 0 0.6em; }

/* ---------- Print: only the two pages, at full size ---------- */

@page { size: 8.5in 11in; margin: 0; }

@media print {
  html, body { margin: 0; padding: 0; background: #fff; }
  .toolbar, .picker, .editor { display: none !important; }
  .layout, .preview, .pages { display: block; padding: 0; margin: 0; position: static; }
  .sheet-frame { width: auto !important; height: auto !important; box-shadow: none; overflow: visible; }
  .sheet { transform: none !important; break-after: page; }
  .sheet-frame:last-child .sheet { break-after: auto; }
  .fit.is-overflow { outline: none; }
}
