:root {
  --bg: #0b1220;
  --surface: #152038;
  --text: #f5f7fb;
  --muted: #b8c2d6;
  --accent: #f4d35e;
  --accent-text: #0b1220;
  --border: #3a4a6a;
  --focus: #7ec8ff;
  --passage-size: 2.2rem;
  --line: 1.55;
  --radius: 14px;
  --pad: 1rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", Times, serif;
  background: var(--bg);
  color: var(--text);
  line-height: var(--line);
}

.noscript {
  max-width: 42rem;
  margin: 1rem auto;
  padding: 0 var(--pad);
  font-size: 1.25rem;
  line-height: 1.45;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.75rem 1rem;
  z-index: 10;
}

.skip-link:focus {
  left: 0.75rem;
  top: 0.75rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: calc(0.85rem + env(safe-area-inset-top, 0px)) var(--pad) 0.65rem;
  border-bottom: 2px solid var(--border);
}

.top-main {
  flex: 1 1 auto;
  min-width: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.brand {
  margin: 0;
  min-width: 0;
  font-size: clamp(1.65rem, 5.2vw, 2.05rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent);
  overflow-wrap: break-word;
  text-wrap: balance;
}

.holiday-holly {
  display: none;
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  line-height: 0;
}

html.is-holiday .holiday-holly {
  display: block;
}

.holiday-holly svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sub {
  margin: 0.25rem 0 0;
  font-size: 1.05rem;
  color: var(--muted);
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.font-corner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.font-size-caption,
.font-size-label {
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-weight: 700;
  color: var(--muted);
}

.font-size-caption {
  font-size: 1.05rem;
  margin-right: 0.15rem;
}

.font-size-label {
  min-width: 3.6rem;
  text-align: center;
  font-size: 1rem;
  line-height: 1.2;
}

.contrast-toggle {
  min-height: 3.6rem;
  padding: 0.75rem 1.1rem;
  font-size: 1.2rem;
}

.contrast-toggle[aria-pressed="true"] {
  background: #ffff00;
  color: #000000;
  border-color: #000000;
}

.btn-font {
  min-width: 3rem;
  min-height: 3rem;
  padding: 0.4rem 0.55rem;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}

.main {
  max-width: 42rem;
  margin: 0 auto;
  padding: var(--pad);
  padding-bottom: calc(2rem + var(--safe-bottom));
}

.date-label {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--muted);
  text-align: center;
  text-wrap: balance;
}

.advent-label {
  margin: -0.2rem 0 0.75rem;
  text-align: center;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--accent);
}

.passage.is-advent {
  border-color: #1f6b3a;
}

.advent-toggle {
  width: 100%;
}

.passage,
.meaning-panel,
.church-dialog,
.church-notice,
.church-updates,
.trial-note,
.input {
  color-scheme: light;
}

.passage {
  background: #ffffff;
  color: #111111;
  border-radius: calc(var(--radius) + 2px);
  padding: 1.35rem 1.15rem 1.1rem;
  border: 4px solid #111111;
  margin-bottom: 1rem;
}

.reference {
  margin: 0 0 0.9rem;
  font-size: calc(var(--passage-size) * 0.9);
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-weight: 800;
  line-height: 1.25;
  color: #111111;
  overflow-wrap: break-word;
}

.passage-text {
  margin: 0;
  font-size: var(--passage-size);
  line-height: 1.65;
  letter-spacing: 0.01em;
  overflow-wrap: break-word;
}

.translation-note {
  margin: 1rem 0 0;
  font-size: 1.05rem;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  color: #333333;
}

.btn-row {
  display: grid;
  gap: 0.65rem;
}

.primary-row {
  grid-template-columns: 1fr;
  margin-bottom: 0.85rem;
}

.secondary-row,
.secondary-row.has-next {
  grid-template-columns: 1fr;
}

.btn {
  min-height: 3.6rem;
  padding: 0.85rem 0.9rem;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  border-radius: var(--radius);
  border: 3px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:focus-visible,
.select:focus-visible,
.btn-font:focus-visible,
.input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent-border, #d4b63a);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-quiet {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  min-height: 2.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.stop-btn {
  width: 100%;
  margin: 0 0 0.85rem;
  color: var(--text);
  border-color: var(--text);
  font-size: 1.15rem;
  min-height: 3.6rem;
}

.btn[aria-pressed="true"] {
  box-shadow: inset 0 0 0 3px #0b1220;
}

.btn:disabled {
  color: var(--muted);
  border-style: dashed;
  cursor: default;
}

.meaning-panel {
  background: #f3f6fb;
  color: #111111;
  border: 3px solid #2a3a55;
  border-radius: var(--radius);
  padding: 1.1rem 1rem 1rem;
  margin-bottom: 1.1rem;
}

.meaning-heading {
  margin: 0 0 0.65rem;
  font-size: 1.35rem;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-weight: 800;
}

.modern-text {
  margin: 0 0 0.85rem;
  font-size: calc(var(--passage-size) * 0.78);
  line-height: 1.55;
  overflow-wrap: break-word;
}

.in-short-block {
  margin: 0;
  font-size: calc(var(--passage-size) * 0.72);
  line-height: 1.45;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  overflow-wrap: break-word;
}

.in-short-label {
  font-weight: 800;
  margin-right: 0.35rem;
}

.secondary {
  display: grid;
  gap: 0.75rem;
  margin: 0.25rem 0 1.35rem;
  padding: 0.85rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field-label {
  font-size: 1rem;
  font-weight: 700;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--muted);
}

.select {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.65rem 0.85rem;
  font-size: 1.15rem;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
}

.panel-heading {
  margin: 0 0 0.75rem;
  font-size: 1.3rem;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
}

.favorites-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.favorites-list li {
  display: grid;
  gap: 0.5rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
}

.fav-ref {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  overflow-wrap: break-word;
}

.fav-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.muted {
  color: var(--muted);
  font-size: 1.05rem;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
}

.footer {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 var(--pad) calc(1.5rem + var(--safe-bottom));
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
}

.footer p {
  margin: 0;
}

.footer-church {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

.footer-setup {
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 2px;
}

.footer-setup:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

img.church-logo:not([hidden]) {
  display: block;
  width: 4.5rem;
  height: 4.5rem;
  object-fit: contain;
  background: #ffffff;
  border-radius: 12px;
  margin: 0 0 0.45rem;
}

.install-hint {
  margin: 0 0 1.1rem;
  padding: 1rem 1rem 1.05rem;
  border-radius: var(--radius);
  border: 3px solid #111111;
  background: #fff8e8;
  color: #1a1408;
  color-scheme: light;
}

.install-hint[hidden] {
  display: none;
}

.install-hint h2 {
  margin: 0 0 0.45rem;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 1.45rem;
  line-height: 1.25;
}

.install-hint p {
  margin: 0 0 0.85rem;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 1.25rem;
  line-height: 1.45;
}

.church-notice:not([hidden]),
.trial-note:not([hidden]) {
  margin: 0 0 0.8rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 3px solid #111111;
  background: #fff8e8;
  color: #1a1408;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 1.15rem;
  line-height: 1.4;
}

.church-notice.offline-note:not([hidden]) {
  font-size: 1.3rem;
  line-height: 1.45;
}

.church-updates:not([hidden]) {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 0.9rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius);
  border: 3px solid #111111;
  background: #fff8e8;
  color: #1a1408;
}

.church-update {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 1.25rem;
  line-height: 1.45;
  font-weight: 700;
}

.input {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.7rem 0.85rem;
  font-size: 1.25rem;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  color: #111111;
  background: #ffffff;
  border: 3px solid #111111;
  border-radius: var(--radius);
}

.church-dialog {
  width: min(32rem, calc(100% - 1.5rem));
  border: 4px solid #111111;
  border-radius: 18px;
  padding: 1.25rem 1.15rem 1.1rem;
  background: #ffffff;
  color: #111111;
}

.church-dialog::backdrop {
  background: rgba(11, 18, 32, 0.72);
}

.church-dialog h2 {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
}

.church-dialog p {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  line-height: 1.45;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
}

.church-dialog .field-label {
  color: #333333;
}

.church-dialog .btn-row {
  margin-top: 0.9rem;
}

.dialog-error:empty {
  display: none;
}

.dialog-error {
  color: #7a1f1f;
  font-weight: 700;
  min-height: 1.4rem;
}

@media (max-width: 639px) {
  .top {
    flex-direction: column;
    align-items: stretch;
  }

  .font-corner {
    width: 100%;
    justify-content: flex-end;
  }

  .contrast-toggle {
    width: 100%;
  }

  .font-size-caption {
    margin-right: auto;
  }

  .brand {
    font-size: 1.85rem;
  }
}

@media (min-width: 640px) {
  .passage {
    padding: 1.75rem 1.5rem 1.25rem;
  }

  .primary-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .secondary-row {
    grid-template-columns: 1fr 1fr;
  }

  .secondary-row.has-next {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .font-size-caption {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

html.high-contrast {
  --bg: #000000;
  --surface: #000000;
  --text: #ffffff;
  --muted: #ffffff;
  --accent: #ffff00;
  --accent-text: #000000;
  --accent-border: #ffff00;
  --border: #ffffff;
  --focus: #ffff00;
  color-scheme: dark;
  background: #000000;
}

html.high-contrast body,
html.high-contrast .passage,
html.high-contrast .meaning-panel,
html.high-contrast .install-hint,
html.high-contrast .church-notice,
html.high-contrast .church-updates,
html.high-contrast .trial-note,
html.high-contrast .church-dialog,
html.high-contrast .input,
html.high-contrast .select,
html.high-contrast .btn-secondary,
html.high-contrast .btn-font,
html.high-contrast .favorites-list li {
  background: #000000;
  color: #ffffff;
  color-scheme: dark;
}

html.high-contrast .passage,
html.high-contrast .meaning-panel,
html.high-contrast .install-hint,
html.high-contrast .church-notice,
html.high-contrast .church-updates,
html.high-contrast .trial-note,
html.high-contrast .church-dialog,
html.high-contrast .input,
html.high-contrast .select,
html.high-contrast .btn,
html.high-contrast .passage.is-advent {
  border-color: #ffff00;
}

html.high-contrast .reference,
html.high-contrast .passage-text,
html.high-contrast .translation-note,
html.high-contrast .modern-text,
html.high-contrast .meaning-heading,
html.high-contrast .in-short-block,
html.high-contrast .in-short-label,
html.high-contrast .church-dialog,
html.high-contrast .church-dialog h2,
html.high-contrast .church-dialog p,
html.high-contrast .church-dialog .field-label,
html.high-contrast .install-hint,
html.high-contrast .install-hint h2,
html.high-contrast .install-hint p,
html.high-contrast .date-label,
html.high-contrast .sub,
html.high-contrast .font-size-label,
html.high-contrast .font-size-caption,
html.high-contrast .field-label,
html.high-contrast .panel-heading,
html.high-contrast .fav-ref,
html.high-contrast .muted,
html.high-contrast .footer,
html.high-contrast .church-update,
html.high-contrast .dialog-error {
  color: #ffffff;
}

html.high-contrast .brand,
html.high-contrast .advent-label,
html.high-contrast .footer-setup,
html.high-contrast .btn-quiet,
html.high-contrast a {
  color: #ffff00;
}

html.high-contrast .btn-primary,
html.high-contrast .contrast-toggle[aria-pressed="true"],
html.high-contrast .skip-link {
  background: #ffff00;
  color: #000000;
  border-color: #ffff00;
}

html.high-contrast .btn-secondary,
html.high-contrast .btn-font,
html.high-contrast .select {
  background: #000000;
  color: #ffffff;
  border-color: #ffffff;
}

html.high-contrast .btn:disabled {
  color: #ffff00;
  border-color: #ffff00;
  background: #000000;
}

html.high-contrast .footer-setup {
  text-decoration-thickness: 3px;
}

html.high-contrast .btn:focus-visible,
html.high-contrast .select:focus-visible,
html.high-contrast .btn-font:focus-visible,
html.high-contrast .input:focus-visible,
html.high-contrast a:focus-visible,
html.high-contrast .skip-link:focus {
  outline: 5px solid #ffff00;
  outline-offset: 4px;
}

html.high-contrast .contrast-toggle[aria-pressed="true"] {
  background: #ffff00;
  color: #000000;
  border-color: #000000;
}

@media (forced-colors: active) {
  .btn,
  .select,
  .input,
  .passage,
  .meaning-panel,
  .church-dialog {
    border-color: ButtonText;
  }
}
