:root {
  --ink: #0F1B33;
  --ink-2: #16244A;
  --ink-3: #1D2E5A;
  --gold: #C9A227;
  --gold-light: #E4C766;
  --garnet: #7A2331;
  --garnet-light: #9C3346;
  --parchment: #F6F1E4;
  --parchment-2: #EFE7D2;
  --ink-text: #1B2A4A;
  --muted: #6B7690;
  --line: rgba(201,162,39,0.18);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: "New York", Georgia, "Iowan Old Style", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--ink);
  color: var(--parchment);
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
}
body.light {
  background: var(--parchment);
  color: var(--ink-text);
}
input, textarea { -webkit-user-select: text; user-select: text; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* Top bar */
.topbar {
  padding: calc(var(--safe-top) + 10px) 20px 12px;
  display: flex; align-items: baseline; justify-content: space-between;
  flex-shrink: 0;
}
.topbar h1 {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 0;
  letter-spacing: 0.2px;
}
.topbar .sub { font-size: 13px; color: var(--gold); font-weight: 600; }

/* Scroll area */
.screen {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px calc(100px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}
.screen.hidden { display: none; }
.hidden { display: none !important; }

/* Cards */
.card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
body.light .card { background: #fff; border-color: rgba(122,35,49,0.12); box-shadow: 0 1px 3px rgba(27,42,74,0.06); }

.card h2, .card h3 { font-family: var(--font-display); margin: 0 0 10px; font-weight: 600; }
.card h3 { font-size: 17px; }
.eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--gold); font-weight: 700; margin-bottom: 6px;
}
.eyebrow::before { content: "☦ "; font-size: 10px; opacity: 0.85; }

.divider-gold {
  height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.5; margin: 16px 0; position: relative;
}
.divider-gold::after {
  content: "☦"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--ink-2); color: var(--gold); font-size: 13px; padding: 0 8px;
}
body.light .divider-gold::after { background: #fff; }
.icon-banner {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 16px 14px; margin-bottom: 14px; cursor: pointer;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
}
body.light .icon-banner { background: #fff; }
.icon-banner img {
  width: 100%; max-width: 220px; height: 180px; border-radius: 12px; object-fit: cover;
  border: 2px solid var(--gold); flex-shrink: 0; background: var(--ink-3); margin-bottom: 10px;
}
.icon-banner .cap { font-size: 11.5px; color: var(--gold-light); line-height: 1.35; font-weight: 600; }
.icon-banner .tap-hint { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* Home hero */
.hero-dates { display: flex; justify-content: space-between; align-items: center; }
.hero-dates .date-block { }
.hero-dates .date-block .greg { font-size: 13px; color: var(--muted); }
.hero-dates .date-block .coptic { font-family: var(--font-display); font-size: 19px; margin-top: 2px; }

.ring-row { display: flex; align-items: center; gap: 18px; margin-top: 14px; }
.ring-wrap { position: relative; width: 108px; height: 108px; flex-shrink: 0; }
.ring-stats { flex: 1; }
.ring-stats .pct { font-family: var(--font-display); font-size: 26px; }
.ring-stats .label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.verse-text { font-family: var(--font-display); font-size: 17px; line-height: 1.5; font-style: italic; }
.verse-ref { margin-top: 8px; font-size: 12px; color: var(--gold); font-weight: 600; }

.mini-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.mini-stat { text-align: center; padding: 10px 6px; background: var(--ink-3); border-radius: 12px; }
body.light .mini-stat { background: var(--parchment-2); }
.mini-stat .n { font-family: var(--font-display); font-size: 20px; color: var(--gold-light); }
body.light .mini-stat .n { color: var(--garnet); }
.mini-stat .l { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* Lists */
.row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .name { font-size: 15px; }
.row .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.check {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer;
}
.check.done { background: var(--gold); }
.check.done::after { content: "✓"; color: var(--ink); font-size: 14px; font-weight: 900; }

.pill {
  display: inline-block; padding: 4px 10px; border-radius: 100px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  background: rgba(201,162,39,0.15); color: var(--gold-light);
}
body.light .pill { background: rgba(122,35,49,0.1); color: var(--garnet); }
.pill.fast { background: rgba(122,35,49,0.22); color: #E38B98; }
body.light .pill.fast { background: rgba(122,35,49,0.12); color: var(--garnet); }

/* Buttons */
.btn {
  border: none; border-radius: 14px; padding: 13px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  font-family: var(--font-body);
}
.btn.primary { background: var(--gold); color: var(--ink); width: 100%; }
.btn.ghost { background: transparent; color: var(--gold); border: 1.5px solid var(--gold); }
.btn.block { width: 100%; margin-top: 8px; }
.btn.danger { color: var(--garnet-light); background: transparent; border: 1.5px solid var(--garnet-light); }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around;
  background: rgba(15,27,51,0.92); backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(6px + var(--safe-bottom));
  z-index: 50;
}
body.light .tabbar { background: rgba(246,241,228,0.92); }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 9.5px; font-weight: 600;
  background: none; border: none; padding: 4px 2px; cursor: pointer;
  flex: 1; min-width: 0;
}
.tab .icon { font-size: 19px; line-height: 1; filter: grayscale(1) opacity(0.6); }
.tab.active { color: var(--gold-light); }
body.light .tab.active { color: var(--garnet); }
.tab.active .icon { filter: none; }

/* More grid */
.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.more-item {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 12px; text-align: left; cursor: pointer; color: inherit;
  font-family: var(--font-body);
}
body.light .more-item { background: #fff; }
.more-item .ic { font-size: 24px; }
.more-item .t { font-size: 13.5px; font-weight: 700; margin-top: 8px; }
.more-item .d { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Sub page (pushed over More) */
.subpage {
  position: fixed; inset: 0; background: var(--ink);
  z-index: 100; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.28s cubic-bezier(.32,.72,0,1);
}
body.light .subpage { background: var(--parchment); }
.subpage.open { transform: translateX(0); }
.subpage-bar {
  padding: calc(var(--safe-top) + 10px) 16px 12px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
.subpage-bar .back { color: var(--gold); font-size: 16px; font-weight: 600; background: none; border: none; cursor: pointer; }
.subpage-bar h2 { font-family: var(--font-display); font-size: 19px; margin: 0; }
.subpage-body { flex: 1; overflow-y: auto; padding: 14px 16px calc(40px + var(--safe-bottom)); -webkit-overflow-scrolling: touch; }

/* Fields */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--ink-3); color: inherit;
  font-size: 15px; font-family: var(--font-body);
}
body.light .field input, body.light .field select, body.light .field textarea { background: var(--parchment-2); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 2px; }
.switch { position: relative; width: 46px; height: 27px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0; background: var(--ink-3);
  border-radius: 100px; transition: 0.2s;
}
.slider::before {
  content: ""; position: absolute; height: 21px; width: 21px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--gold); }
.switch input:checked + .slider::before { transform: translateX(19px); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ic { font-size: 34px; margin-bottom: 10px; }
.empty .t { font-family: var(--font-display); font-size: 17px; color: inherit; margin-bottom: 4px; }
.empty .d { font-size: 13px; max-width: 260px; margin: 0 auto; }

.badge-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.badge {
  text-align: center; padding: 14px 6px; border-radius: 14px;
  background: var(--ink-3); border: 1px solid var(--line);
}
body.light .badge { background: var(--parchment-2); }
.badge.locked { opacity: 0.35; }
.badge .ic { font-size: 26px; }
.badge .t { font-size: 10.5px; margin-top: 6px; font-weight: 700; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 13px; border-radius: 100px; background: var(--ink-3);
  border: 1px solid var(--line); font-size: 13px; cursor: pointer;
}
body.light .chip { background: var(--parchment-2); }
.chip.on { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 700; }

.toast {
  position: fixed; bottom: calc(96px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--gold); color: var(--ink); padding: 10px 18px; border-radius: 100px;
  font-size: 13px; font-weight: 700; z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

.chat-bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; margin-bottom: 10px; font-size: 14px; line-height: 1.45; }
.chat-bubble.bot { background: var(--ink-3); border-bottom-left-radius: 4px; }
body.light .chat-bubble.bot { background: var(--parchment-2); }
.chat-bubble.me { background: var(--gold); color: var(--ink); margin-left: auto; border-bottom-right-radius: 4px; font-weight: 600; }
.chat-input-row { display: flex; gap: 8px; position: sticky; bottom: 0; padding-top: 8px; background: inherit; }
.chat-input-row input { flex: 1; }

a.link { color: var(--gold-light); text-decoration: none; font-weight: 600; }
body.light a.link { color: var(--garnet); }

::-webkit-scrollbar { display: none; }

@media print {
  body * { visibility: hidden; }
  #subpage-yearreview, #subpage-yearreview * { visibility: visible; }
  #subpage-yearreview { position: absolute; inset: 0; background: #fff !important; color: #111 !important; transform: none !important; }
  #subpage-yearreview .subpage-bar, #yearreview-print-btn, #subpage-yearreview p { display: none !important; }
  #subpage-yearreview .card { border: none !important; background: #fff !important; }
}

/* ---- Full-screen prayer / liturgy reader ---- */
.prayer-reader {
  position: fixed; inset: 0; z-index: 200;
  background: var(--ink); color: inherit;
  display: flex; flex-direction: column;
}
.prayer-reader.hidden { display: none; }
.pr-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 10px) 12px 12px;
  border-bottom: 1px solid var(--line); background: var(--ink-2);
  flex-shrink: 0;
}
.pr-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--ink-3);
  color: var(--gold); font-size: 20px; font-weight: 700;
}
.pr-title-wrap { flex: 1; min-width: 0; }
.pr-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; }
.pr-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(24px + var(--safe-bottom));
  font-size: 15.5px; line-height: 1.7; white-space: pre-wrap;
}
.pr-body .pr-section-title {
  color: var(--gold-light); font-weight: 700; font-size: 14px;
  margin: 18px 0 8px; letter-spacing: 0.02em;
}
.pr-drawer {
  position: absolute; top: 0; bottom: 0; width: min(82vw, 320px);
  background: var(--ink-2); border: 1px solid var(--line);
  z-index: 210; transition: transform 0.25s ease;
  display: flex; flex-direction: column;
  padding-top: calc(var(--safe-top) + 8px);
}
.pr-drawer-left { left: 0; transform: translateX(-105%); border-right: 1px solid var(--line); }
.pr-drawer-right { right: 0; transform: translateX(105%); border-left: 1px solid var(--line); }
.pr-drawer.open { transform: translateX(0); }
.pr-drawer-head {
  padding: 12px 16px; font-size: 12px; color: var(--gold);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.pr-drawer-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.pr-drawer-list button {
  display: block; width: 100%; text-align: left;
  padding: 12px 16px; border: none; background: none;
  color: inherit; font-size: 14px; border-bottom: 1px solid var(--line);
}
.pr-drawer-list button.active { color: var(--gold-light); font-weight: 700; }
.pr-drawer-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.45); z-index: 205;
}
.pr-drawer-backdrop.hidden { display: none; }

/* UI polish — tighter, less generic */
.card { border-radius: 12px; }
.btn { border-radius: 10px; letter-spacing: 0.01em; }
.btn.primary { box-shadow: none; }
.row { border-radius: 0; }
.eyebrow { letter-spacing: 0.08em; opacity: 0.9; }
.tabbar { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.tab .icon { font-size: 18px; }
.empty .ic { opacity: 0.7; }
.pr-body { font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.75; }
.pr-section-title { font-family: var(--font-display), system-ui, sans-serif; }

/* Liturgy picker — clean hierarchy */
.lit-pick { display: flex; flex-direction: column; gap: 8px; }
.lit-card {
  text-align: left; width: 100%;
  padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--ink-2);
  color: inherit; cursor: pointer;
}
.lit-card:active, .lit-card.active {
  border-color: var(--gold); background: var(--ink-3);
}
.lit-card-name { font-weight: 700; font-size: 15px; }
.lit-card-cop {
  font-size: 13px; color: var(--gold-light);
  margin-top: 2px; font-family: "Segoe UI Historic", "Noto Sans Coptic", serif;
}
.lit-card-desc { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.lit-part-name {
  margin: 16px 0 6px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold);
}
.pr-body .pr-cop {
  color: var(--gold-light); font-size: 15px;
  font-family: "Segoe UI Historic", "Noto Sans Coptic", serif;
  margin-bottom: 4px;
}

/* Reader bottom nav + slides */
.pr-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--line); background: var(--ink-2);
  flex-shrink: 0;
}
.pr-nav-btn {
  border: 1px solid var(--line); background: var(--ink-3);
  color: var(--gold); border-radius: 10px; padding: 8px 12px;
  font-size: 13px; font-weight: 600;
}
.pr-nav-btn:disabled { opacity: 0.35; }
.pr-nav-pos { font-size: 12px; color: var(--muted); min-width: 48px; text-align: center; }
.pr-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.pr-slide { min-height: 60vh; display: flex; flex-direction: column; justify-content: flex-start; }
.pr-slide-body { font-size: 17px; line-height: 1.8; }

/* Landscape reader */
@media (orientation: landscape) {
  .prayer-reader { flex-direction: row; flex-wrap: wrap; }
  .pr-topbar { width: 100%; }
  .pr-body {
    flex: 1; height: auto;
    max-height: calc(100vh - 56px - 52px);
    padding: 16px 24px;
    columns: 2; column-gap: 28px;
  }
  .prayer-reader.slides-mode .pr-body { columns: 1; }
  .pr-nav { width: 100%; }
  .pr-drawer { width: min(50vw, 360px); }
  .tabbar { padding-bottom: 4px; }
}

/* Ensure scrollbars visible where needed */
.pr-body, .pr-drawer-list, .subpage-body {
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}
.pr-body::-webkit-scrollbar, .pr-drawer-list::-webkit-scrollbar { width: 6px; }
.pr-body::-webkit-scrollbar-thumb, .pr-drawer-list::-webkit-scrollbar-thumb {
  background: var(--gold); border-radius: 4px;
}

/* Home widgets */
.home-widget {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.home-widget:last-child { border-bottom: none; }
.hw-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--gold); font-weight: 700; margin-bottom: 4px;
}
.hw-value {
  font-size: 14px; line-height: 1.45; color: inherit;
}

/* Bilingual prayer columns */
.pr-bi {
  display: grid;
  gap: 12px 20px;
  margin: 0 0 18px;
  align-items: start;
}
.pr-bi-one { grid-template-columns: 1fr; }
.pr-bi-two { grid-template-columns: 1fr 1fr; }
.pr-bi-three { grid-template-columns: 1fr 1fr 1fr; }
.pr-eng {
  font-size: 17px;
  line-height: 1.75;
  text-align: left;
}
.pr-cop {
  font-size: 16px;
  line-height: 1.7;
  text-align: right;
  direction: ltr;
  color: var(--gold-light);
  font-family: "Segoe UI Historic", "Noto Sans Coptic", "FreeSerif", "Quivira", serif;
}
.pr-ara {
  font-size: 15px;
  line-height: 1.7;
  text-align: right;
  direction: rtl;
  font-family: "Noto Naskh Arabic", "Amiri", "Traditional Arabic", serif;
}
.pr-role {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold);
  font-weight: 700;
  margin-right: 4px;
}
.pr-heading {
  font-family: var(--font-display), system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin: 22px 0 12px;
  color: var(--gold);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.pr-section-title {
  font-size: 18px !important;
  font-weight: 700 !important;
  margin: 16px 0 10px !important;
}
.prayer-reader.large-text .pr-eng { font-size: 19px; }
.prayer-reader.large-text .pr-cop { font-size: 18px; }
.prayer-reader.large-text .pr-heading { font-size: 24px; }
.prayer-reader.large-text .pr-section-title { font-size: 20px !important; }

.lit-section-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--ink-2);
}
.lit-footnote {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 12px;
}

@media (orientation: landscape) {
  .prayer-reader:not(.no-land-cols):not(.slides-mode) .pr-body {
    columns: 2;
    column-gap: 28px;
  }
  .prayer-reader.no-land-cols .pr-body,
  .prayer-reader.slides-mode .pr-body {
    columns: 1;
  }
}
@media (max-width: 520px) {
  .pr-bi-two, .pr-bi-three { grid-template-columns: 1fr; }
  .pr-cop, .pr-ara { text-align: left; }
}
