:root {
  color-scheme: light;
  --ink: #2d2531;
  --muted: #645969;
  --purple: #563876;
  --rule: #e3dae6;
  --serif: Georgia, 'Times New Roman', serif;
  font-family: system-ui, sans-serif;
  color: var(--ink);
  background: #f6f3f7;
}

* { box-sizing: border-box; }
body { margin: 0; }
.startup { max-width: 83rem; margin-inline: auto; padding: 2rem clamp(1rem, 4vw, 3rem); }
button, input, select { font: inherit; }
button {
  min-height: 2.5rem;
  border: 1px solid #d9cce0;
  border-radius: 0.4rem;
  padding: 0.45rem 0.8rem;
  color: var(--purple);
  background: #fff;
  font-weight: 650;
  cursor: pointer;
}
button:hover { background: #f1e9f5; }
a { color: var(--purple); text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid #8360ac; outline-offset: 3px; }

.topbar {
  background: #2f203b;
  color: #fff;
}
.topbar-inner {
  max-width: 83rem;
  margin-inline: auto;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font: 1.2rem var(--serif);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  color: #dbc7ed;
  border: 1px solid #8d739e;
  border-radius: 50%;
  font-size: 0.95rem;
}

main {
  max-width: 83rem;
  margin-inline: auto;
  padding: 2.2rem clamp(1rem, 4vw, 3rem) 3rem;
}
.page-heading, .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.page-heading { margin-bottom: 1.65rem; }
.page-heading p { margin: 0.45rem 0 0; color: var(--muted); }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: var(--serif); font-weight: 500; }
h1 { margin-bottom: 0; font-size: clamp(2.15rem, 5vw, 3.4rem); line-height: 1.05; }
h2 { margin-bottom: 0.9rem; font-size: 1.45rem; }
.primary { color: #fff; background: var(--purple); border-color: var(--purple); padding-inline: 1rem; }
.primary:hover { background: #422858; }
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.98fr) minmax(0, 1.02fr);
  gap: clamp(1rem, 3vw, 2.4rem);
  align-items: start;
}
.editor { display: grid; gap: 1rem; }
.card { background: #fff; border: 1px solid var(--rule); border-radius: 0.6rem; padding: clamp(0.9rem, 2vw, 1.4rem); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.wide { grid-column: 1 / -1; }
label { display: grid; gap: 0.35rem; font-size: 0.875rem; font-weight: 650; min-width: 0; }
input, select {
  width: 100%;
  min-width: 0;
  min-height: 2.6rem;
  border: 1px solid #d9cfdf;
  border-radius: 0.35rem;
  padding: 0.42rem 0.55rem;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 400;
}
#source { display: inline-block; margin-top: 0.9rem; font-size: 0.875rem; }
.section-heading h2 { margin-bottom: 0; }
.muted, .storage-note { color: var(--muted); }
.editor .muted { margin: 0.55rem 0 0.75rem; }
.storage-note { margin: 0; font-size: 0.875rem; }
.service-search { margin-bottom: 1.5rem; }
.service-search .muted { font-size: .875rem; margin: .65rem 0; }
.search-result { border-top: 1px solid var(--rule); padding-block: 1rem; overflow-wrap: anywhere; }
.search-result:first-child { margin-top: .75rem; }
.search-result:last-child { padding-bottom: 0; }
.search-result h3 { margin-bottom: .5rem; font: 600 1.1rem var(--serif); }
.search-result ul { padding-left: 1.25rem; line-height: 1.5; margin: .5rem 0 .75rem; }
.hymn-entry { border-top: 1px solid var(--rule); padding-bottom: 0.6rem; }
.hymn-row {
  display: grid;
  grid-template-columns: minmax(5rem, 0.9fr) minmax(0, 1.6fr) minmax(5.5rem, 0.8fr) auto;
  align-items: end;
  gap: 0.45rem;
  padding-block: 0.6rem;
}
.remove { padding-inline: 0.6rem; font-size: 1.15rem; line-height: 1; min-height: 2.6rem; }
.hymn-suggestions > summary {
  width: fit-content;
  padding-block: 0.2rem;
  color: var(--purple);
  font-size: 0.875rem;
  font-weight: 650;
  cursor: pointer;
}
.hymn-usage { margin: 0.25rem 0; font-size: 0.875rem; color: var(--muted); }
.history > summary { font: 1.3rem var(--serif); cursor: pointer; }
.history label { margin: 0.8rem 0; }
.history-list details { padding-block: 0.55rem; border-top: 1px solid var(--rule); overflow-wrap: anywhere; }
.history-list summary { font-weight: 650; cursor: pointer; }
.history-list summary .hymn-usage { display: block; font-weight: 400; padding-left: 1.1rem; }
.history-list ul { margin: 0.4rem 0 0; padding-left: 1.4rem; }
.suggestion-content {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border-radius: 0.4rem;
  background: #f6f1f8;
}
.suggestion-content > p:last-child { margin-bottom: 0; }
.suggestion-label { margin: 0.35rem 0 0.45rem; font-size: 0.875rem; color: var(--muted); }
.suggestion-list { display: grid; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.suggestion-list li { padding: 0.65rem; background: #fff; border: 1px solid var(--rule); border-radius: 0.35rem; }
.suggestion-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.35rem 0.7rem; margin-top: 0.25rem; }
.suggestion-actions a, .suggestion-rationale a { font-size: 0.875rem; }
.suggestion-actions button { min-height: 2rem; padding: 0.25rem 0.55rem; font-size: 0.875rem; }
.suggestion-rationale { margin-top: 0.5rem; padding-top: 0.6rem; border-top: 1px solid var(--rule); }
.suggestion-rationale p { margin: 0 0 0.4rem; line-height: 1.45; }

.preview {
  min-width: 0;
  background: #ece6ef;
  border: 1px solid #e3dae6;
  border-radius: 0.65rem;
  padding: clamp(0.75rem, 2vw, 1.35rem);
}
.preview > h2 { font: 650 0.875rem system-ui, sans-serif; color: var(--muted); margin: 0 0 0.85rem; }
.sheet {
  background: #fff;
  color: var(--ink);
  padding: clamp(1.1rem, 3vw, 2.25rem);
  border-top: 4px solid var(--purple);
  box-shadow: 0 2px 12px #38264315;
  overflow-wrap: anywhere;
}
.sheet-heading { text-align: center; padding-bottom: 0.65rem; }
.sheet-heading p { margin: 0 0 0.45rem; }
.sheet-heading h2 { font-size: clamp(1.7rem, 3vw, 2.45rem); line-height: 1.07; margin: 0.35rem 0; }
.sheet-date, .parish { font-size: 0.875rem; color: var(--muted); }
.color {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  font-weight: 650;
}
.swatch { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--purple); }
.swatch.blue { background: #365f99; }
.swatch.green { background: #346544; }
.swatch.red { background: #a33737; }
.swatch.white { background: #fff; border: 1px solid #9b909e; }
.reading-set-note { margin: 0 0 0.45rem; color: var(--muted); font-size: 0.875rem; }
#alternatives { display: grid; gap: 0.85rem; }
#alternatives[hidden] { display: none; }
.sheet-section { border-top: 1px solid var(--rule); padding: 0.8rem 0; }
.sheet-section:last-child { padding-bottom: 0; }
.sheet-section h3 { font: 600 1.15rem var(--serif); margin: 0 0 0.6rem; }
.sheet-section p { margin-bottom: 0; line-height: 1.5; }
.sheet-section dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr);
  gap: 0.4rem 0.5rem;
  margin: 0;
}
.sheet-section dt, .sheet-section li span { color: var(--muted); }
.sheet-section dd { margin: 0; font-weight: 600; }
.sheet-section ul { list-style: none; padding: 0; margin: 0; }
.sheet-section li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr);
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.sheet-section li:last-child { margin-bottom: 0; }

@media screen and (max-width: 850px) {
  .workspace { grid-template-columns: 1fr; }
}
@media screen and (max-width: 470px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .hymn-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .hymn-row label:nth-child(2) { grid-row: 2; grid-column: 1 / -1; }
}

/* The offscreen copy and the printed sheet use the same typesetting. */
.sheet.measure {
  position: absolute;
  left: -10000px;
  top: 0;
  visibility: hidden;
}
.sheet.measure {
  width: 7.4in;
  padding: 0.15in 0 0;
  box-shadow: none;
  font-size: 11pt;
}
.sheet.measure .sheet-heading h2 { font-size: 24pt; }

@page { size: letter portrait; margin: 0.55in; }
@media print {
  :root, body { background: white; }
  .topbar, .startup, .page-heading, .service-search, .editor, .preview > h2 { display: none; }
  main, .workspace, .preview {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: white;
  }
  #sheet {
    width: 7.4in;
    margin-inline: auto;
    padding: 0.15in 0 0;
    box-shadow: none;
    font-size: 11pt;
    zoom: var(--print-scale, 1);
  }
  #sheet .sheet-heading h2 { font-size: 24pt; }
}
/* Account controls are outside the printed service sheet. */
.account-bar { display: flex; gap: 1rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; padding: .7rem 1.5rem; font-size: .85rem; }
.account-bar form { margin: 0; }
@media print { .account-bar { display: none !important; } }
