:root {
  color-scheme: light;
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --ink: #1d1d1f;
  --ink-secondary: #6e6e73;
  --ink-tertiary: #8e8e93;
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --fill: #e5e5ea;
  --fill-strong: #d1d1d6;
  --separator: rgba(60, 60, 67, 0.12);
  --danger: #ff3b30;
  --success: #34c759;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
  --radius: 20px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --chrome: #d8d8de;
}

html[data-theme="dark"],
html[data-theme="auto"][data-system="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --ink: #f5f5f7;
  --ink-secondary: #98989d;
  --ink-tertiary: #8e8e93;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --fill: #2c2c2e;
  --fill-strong: #3a3a3c;
  --separator: rgba(84, 84, 88, 0.45);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --chrome: #0b0b0d;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; -webkit-tap-highlight-color: transparent; }
body {
  min-height: 100%;
  font-family: var(--font);
  background: var(--chrome);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
  touch-action: manipulation;
}

a { color: var(--accent); text-decoration: none; }

.device {
  width: min(100%, 430px);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
}

.device.is-wide {
  width: min(100%, 840px);
}

@media (min-width: 520px) {
  body { padding: 24px 16px; }
  .device {
    min-height: calc(100dvh - 48px);
    border-radius: 34px;
    box-shadow: var(--shadow), 0 0 0 1px var(--separator);
  }
}

@media (max-width: 519px) {
  body { background: var(--bg); }
}

.screen {
  padding: calc(var(--safe-top) + 28px) 20px calc(var(--safe-bottom) + 28px);
}

.page-home .screen,
.page-admin .screen {
  padding-top: calc(var(--safe-top) + 8px);
}

.theme-toggle-slot {
  display: flex;
  justify-content: flex-end;
  margin: 0 8px;
  pointer-events: none;
}

.theme-toggle-slot .theme-toggle {
  pointer-events: auto;
}

.home-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: 0 -8px 8px;
}

.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun,
html[data-theme="auto"][data-system="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon,
html[data-theme="auto"][data-system="dark"] .theme-toggle .icon-moon { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: calc(var(--safe-top) + 8px) 8px 10px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  cursor: pointer;
  flex: 0 0 auto;
}

.icon-btn.ink { color: var(--ink); }
.icon-btn.danger { color: var(--danger); }
.icon-btn:active { opacity: 0.55; }
.icon-btn svg { width: 22px; height: 22px; }

.link-btn {
  appearance: none;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 17px;
  font-weight: 400;
  padding: 10px 8px;
  cursor: pointer;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 8px;
}

.brand-mark {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #1c1c1e;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

html[data-theme="dark"] .brand-mark,
html[data-theme="auto"][data-system="dark"] .brand-mark {
  filter: invert(1);
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.08);
}

.brand-sm {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  margin: 12px 0 8px;
}

.brand-sm .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
}

.brand-name {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}

.hero h1, .large-title {
  margin: 0;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.verse {
  margin: 18px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.verse-ref {
  display: inline-flex;
  margin-top: 10px;
  font-style: normal;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}

.lede, .prose {
  color: var(--ink-secondary);
  font-size: 16px;
  line-height: 1.5;
}

.prose p { margin: 0 0 12px; }
.prose p:last-child { margin-bottom: 0; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: 980px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-align: center;
  width: 100%;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); opacity: 0.88; }
.btn-primary { background: var(--ink); color: var(--bg-elevated); }
.btn-secondary { background: var(--fill); color: var(--ink); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 18px 18px;
  box-shadow: 0 1px 0 var(--separator);
}

.group {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-height: 52px;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.row + .row, .pray-item + .pray-item, .field + .field {
  border-top: 0.5px solid var(--separator);
}

.row-body { flex: 1; min-width: 0; }
.row-title {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.row-meta {
  margin-top: 2px;
  font-size: 13px;
  color: var(--ink-secondary);
}
.chevron {
  color: var(--ink-tertiary);
  flex: 0 0 auto;
}

.section-label {
  margin: 8px 4px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.progress-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.bar {
  flex: 1;
  height: 4px;
  background: var(--fill);
  border-radius: 99px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.muted { color: var(--ink-secondary); }
.center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

/* Prayer */
.prayer-body {
  padding: 8px 16px 120px;
}

.section-pane { display: none; }
.section-pane.is-active { display: block; }

.section-kicker {
  margin: 12px 4px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.section-heading {
  margin: 0 4px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.section-scripture {
  margin: 8px 4px 0;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-secondary);
  font-size: 15px;
}

.sub-scripture {
  margin: -4px 8px 8px;
  font-size: 12px;
  color: var(--ink-tertiary);
  font-family: var(--serif);
  font-style: italic;
}

.scripture-line {
  appearance: none;
  border: 0;
  background: transparent;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.scripture-copy {
  flex: 1;
  min-width: 0;
}

.scripture-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-top: -6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: transparent;
}

.scripture-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.scripture-line:active .scripture-icon {
  background: var(--accent-soft);
  transform: scale(0.94);
}

.overlay[data-scripture-overlay] { z-index: 80; }
.sheet[data-scripture-sheet] { z-index: 90; }

.spinner {
  width: 28px;
  height: 28px;
  margin: 28px auto;
  border: 2.5px solid var(--fill-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.passage {
  margin: 0 0 22px;
}

.passage h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.passage-text {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
}

.verse-num {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  margin-right: 3px;
  vertical-align: super;
}

.scripture-translation {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ink-tertiary);
}

.scripture-status {
  padding: 18px 4px;
  text-align: center;
  color: var(--ink-secondary);
  font-size: 15px;
}

.scripture-status.error { color: var(--danger); }

.section-intro {
  margin: 14px 0 18px;
  color: var(--ink-secondary);
  font-size: 16px;
  line-height: 1.5;
}

.sub-block { margin-bottom: 18px; }

.group-kicker {
  margin: 4px 8px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.sub-title {
  margin: 0 8px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.pray-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.tick {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: -10px -10px 0 -12px;
  border: 0;
  background: transparent;
  position: relative;
}

.tick::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--fill-strong);
  background: transparent;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.tick::after {
  content: "";
  position: absolute;
  left: 19px;
  top: 14px;
  width: 7px;
  height: 12px;
  border: 2px solid #fff;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.pray-item.is-checked .tick::before {
  background: var(--accent);
  border-color: var(--accent);
}

.pray-item.is-checked .tick::after { transform: rotate(45deg) scale(1); }
.pray-item.is-checked .pray-text { color: var(--ink-secondary); }

.pray-text {
  flex: 1;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.note-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--ink-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.note-btn.has-note { color: var(--accent); background: var(--accent-soft); }
.note-btn svg { width: 16px; height: 16px; }

.note-field {
  padding: 0 14px 14px 50px;
}

.note-field textarea,
.field textarea,
.field input,
.field select,
.sheet-field {
  width: 100%;
  border: 0;
  background: var(--fill);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  line-height: 1.4;
  outline: none;
  resize: vertical;
  min-height: 88px;
}

.field input, .field select {
  min-height: 44px;
  resize: none;
}

.field {
  padding: 12px 16px;
  background: var(--bg-elevated);
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.dock {
  position: sticky;
  bottom: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  gap: 8px;
  align-items: center;
  padding: 10px 16px calc(var(--safe-bottom) + 12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}

.dock .btn { min-height: 44px; width: auto; padding: 0 16px; }
.progress-copy {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
}
.progress-copy strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 2px;
}

/* Sheets / overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 40;
}

.overlay.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 110%);
  width: min(100%, 430px);
  max-height: min(88dvh, 760px);
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  z-index: 50;
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}

.device.is-wide .sheet { width: min(100%, 840px); }

.sheet.is-open { transform: translate(-50%, 0); }

.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: 99px;
  background: var(--fill-strong);
  margin: 8px auto 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 10px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.sheet-body {
  overflow: auto;
  padding: 0 16px 20px;
  -webkit-overflow-scrolling: touch;
}

.toc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 4px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  border-bottom: 0.5px solid var(--separator);
}

.toc-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--fill);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.toc-item.is-current .toc-num {
  background: var(--accent);
  color: #fff;
}

.save-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.save-dot.is-on { opacity: 1; }

.flash {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
}

.flash.error { background: rgba(255, 59, 48, 0.12); color: var(--danger); }

.admin-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 18px;
}

.admin-toolbar .btn { width: auto; min-height: 40px; padding: 0 16px; font-size: 15px; }

.editor-section {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.editor-item {
  background: var(--fill);
  border-radius: 12px;
  padding: 10px;
  margin-top: 8px;
}

.editor-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.mini {
  appearance: none;
  border: 0;
  background: var(--bg-elevated);
  color: var(--ink);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
}

.badge {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--fill);
  color: var(--ink-secondary);
}

.badge-pending { background: rgba(255, 159, 10, 0.16); color: #c93400; }
.badge-approved { background: rgba(52, 199, 89, 0.16); color: #1f8a3b; }
.badge-disabled { background: rgba(255, 59, 48, 0.12); color: var(--danger); }

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.user-actions .mini {
  width: auto;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
}

.login-card {
  margin-top: 24px;
}

.empty {
  padding: 22px 8px;
  text-align: center;
  color: var(--ink-secondary);
}

details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "›"; float: right; color: var(--ink-tertiary); font-size: 20px; }

.hidden { display: none !important; }

@media (min-width: 840px) {
  .device.is-wide .sheet { left: 50%; }
}
