:root {
  /* ----- Light theme (default) ----- */
  --color-primary: #5d4037;
  --color-primary-dark: #3e2723;
  --color-on-primary: #ffffff;
  --color-surface: #ffffff;
  --color-background: #faf6f1;
  --color-text: #2b1a14;
  --color-text-muted: #6d5b53;
  --color-accent: #c9a25b;
  --color-star: #f4b400;
  --color-divider: #e7ddd3;
  --color-ok: #2e7d32;
  --color-error: #b3261e;

  /* Surfaces / overlays that depend on contrast direction */
  --card-active-bg: #f4ece1;
  --icon-wrap-bg: linear-gradient(135deg, #f7eedc, #e8d6b0);
  --icon-wrap-fg: var(--color-primary-dark);
  --hover-overlay: rgba(0,0,0,0.04);
  --press-overlay: rgba(0,0,0,0.08);
  --star-idle: rgba(0,0,0,0.32);

  --shadow-1: 0 1px 2px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-2: 0 2px 6px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.08);
  --shadow-drag: 0 12px 28px rgba(0,0,0,0.18), 0 4px 10px rgba(0,0,0,0.12);
  --radius: 16px;
  --app-bar-height: 56px;
}

/* ----- Dark theme - same warm Byzantine palette, inverted contrast ----- */
[data-theme="dark"] {
  --color-primary: #2c1810;          /* deep umber for the app bar */
  /* In light theme `--color-primary-dark` was a *darker* brand colour for
     emphasis text on a light surface. On dark surfaces "darker" makes text
     unreadable, so the emphasis role flips to a *lighter* brand tone. */
  --color-primary-dark: #f5d99e;
  --color-on-primary: #f5e6d3;
  --color-surface: #2a201a;          /* card background */
  --color-background: #19120e;       /* page background */
  --color-text: #ede0d0;
  --color-text-muted: #a89888;
  --color-accent: #d4b16a;           /* slightly brighter gold for legibility */
  --color-star: #f4c430;
  --color-divider: #3a302a;
  --color-ok: #6abf6f;
  --color-error: #ef6b62;

  --card-active-bg: #3a2f25;
  --icon-wrap-bg: linear-gradient(135deg, #4a3a2c, #5e4a36);
  /* --icon-wrap-fg cascades from --color-primary-dark above, no override needed */
  --hover-overlay: rgba(255,255,255,0.05);
  --press-overlay: rgba(255,255,255,0.10);
  --star-idle: rgba(255,255,255,0.45);

  --shadow-1: 0 1px 2px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.4);
  --shadow-2: 0 2px 6px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.5);
  --shadow-drag: 0 12px 28px rgba(0,0,0,0.7), 0 4px 10px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

/* ===== Accessibility helpers ===== */
/* Off-screen but readable by screen readers. Standard a11y pattern.
   Used for the homepage <h1>, which is required for landmark navigation
   but isn't part of the visual design. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link for keyboard / screen-reader users - invisible until focused. */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  text-decoration: none;
  border-radius: 0 0 8px 0;
  font-weight: 500;
  transform: translateY(-110%);
  transition: transform 0.18s ease;
}
.skip-link:focus { transform: translateY(0); outline: none; }

/* Visible focus ring for keyboard users only (not for mouse clicks). */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
/* Ensure full-card focus rings respect rounded corners. */
.prayer-card__link-overlay:focus-visible,
.prayer-card__star:focus-visible {
  outline-offset: -2px;
}
.app-bar__nav:focus-visible,
.app-bar__action:focus-visible {
  outline: 2px solid var(--color-on-primary);
  outline-offset: -2px;
}
/* Don't show a focus ring on programmatic focus targets - the SR
   announcement is enough; the visual ring on a non-interactive heading
   would just be confusing. */
#main-content:focus-visible,
.prayer-view__title:focus-visible { outline: none; }

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--color-background);
  color: var(--color-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
  /* Reserve room for the fixed footer's collapsed title bar
     (height of .footer__title + iOS safe-area). */
  padding-bottom: calc(58px + env(safe-area-inset-bottom));
}

/* ===== App bar ===== */
.app-bar {
  position: sticky;
  top: 0;
  height: var(--app-bar-height);
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: var(--shadow-2);
  display: flex;
  align-items: stretch;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
}

/* The whole left+center area is one navigation link to the homepage:
   click anywhere in it (back arrow, brand icon, brand text, blank spacing)
   and we go back to the dashboard. */
.app-bar__nav {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  padding: 0 12px;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.app-bar__nav:active { background: rgba(255,255,255,0.08); }

/* Visual cue that this AppBar takes you back. Shown only on prayer pages -
   on the homepage it's hidden (opacity 0) but takes up the same space so the
   layout doesn't shift. */
.app-bar__back-arrow {
  font-size: 24px;
  flex: 0 0 auto;
  opacity: 1;
  transition: opacity 0.15s ease;
}

.app-bar__back-arrow--hidden {
  opacity: 0;
  pointer-events: none;
}

/* Brand sits absolutely centered relative to the nav link, so it stays
   visually balanced regardless of whether the back arrow or action buttons
   are present. pointer-events: none lets clicks pass through to the link. */
.app-bar__brand {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 96px);
}

.app-bar__icon { font-size: 26px; flex: 0 0 auto; }

.app-bar__title {
  font-size: 18px;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-bar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
  flex: 0 0 auto;
}

@media (max-width: 380px) {
  .app-bar__title { font-size: 16px; }
  .app-bar__icon { font-size: 22px; }
}

.app-bar__action {
  background: rgba(255,255,255,0.16);
  color: var(--color-on-primary);
  border: 0;
  border-radius: 18px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.app-bar__action:hover { background: rgba(255,255,255,0.24); }
.app-bar__action:active { background: rgba(255,255,255,0.32); }

.app-bar__action--install {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 8px 10px;
}
.app-bar__action--install .material-icons-round { font-size: 18px; }
@media (max-width: 380px) {
  .app-bar__action--install span:not(.material-icons-round) { display: none; }
  .app-bar__action--install { padding: 8px; border-radius: 50%; }
}

.ios-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px 0;
  padding: 10px 12px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: var(--shadow-1);
}
.ios-banner__icon { font-size: 22px; flex: 0 0 auto; color: var(--color-accent); }
.ios-banner__text { flex: 1; }
.ios-banner__text strong { color: var(--color-accent); font-weight: 600; }
.ios-banner__close {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 4px;
  cursor: pointer;
  display: flex;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.ios-banner__close:hover { background: rgba(255,255,255,0.16); }
.ios-banner__close .material-icons-round { font-size: 18px; }

/* ===== Content / sections ===== */
.content {
  padding: 12px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 960px;
  margin: 0 auto;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 4px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.section-label--fav { color: var(--color-star); }
.section-label .material-icons-round { font-size: 18px; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (min-width: 480px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 12px; } }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(5, 1fr); gap: 14px; } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(6, 1fr); } }

/* ===== Cards ===== */
.prayer-card {
  position: relative;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 16px 8px 12px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  border: 0;
  font: inherit;
  color: var(--color-text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
  min-height: 124px;
  user-select: none;
  touch-action: pan-y;
}

.prayer-card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.prayer-card:active { background: var(--card-active-bg); }

/* Invisible anchor that covers the whole card. Replaces the previous
   pattern of nesting a <button> inside an <a> (HTML5 invalid). The card
   wrapper is now a plain <div> for valid markup; this overlay carries the
   link semantics + click target. Star button sits at z-index 2 above. */
.prayer-card__link-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  z-index: 1;
}

.prayer-card__icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--icon-wrap-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--icon-wrap-fg);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}

.prayer-card__icon { font-size: 28px; }

.prayer-card__title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  margin: 0;
}

.prayer-card__desc {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.3;
  margin: 0;
}

/* ===== Star button ===== */
.prayer-card__star {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--star-idle);
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s, transform 0.15s;
  padding: 0;
  z-index: 2;
}

.prayer-card__star .material-icons-round { font-size: 20px; }
.prayer-card__star:hover { background: var(--hover-overlay); color: var(--color-star); }
.prayer-card__star:active { transform: scale(0.85); }
.prayer-card__star.is-fav { color: var(--color-star); }

/* ===== Edit mode (jiggle) ===== */
.dashboard.is-editing .prayer-card {
  animation: jiggle 0.22s ease-in-out infinite alternate;
  animation-delay: var(--jiggle-delay, 0s);
  cursor: grab;
  touch-action: none;
}

.dashboard.is-editing .prayer-card:active { cursor: grabbing; }

.dashboard.is-editing .prayer-card.is-dragging {
  animation: none;
  opacity: 0.25;
  box-shadow: var(--shadow-1);
}

@keyframes jiggle {
  from { transform: rotate(-0.9deg); }
  to   { transform: rotate(0.9deg); }
}

/* The floating ghost that follows the finger */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  box-shadow: var(--shadow-drag);
  transform: scale(1.06);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  background: var(--color-surface);
  border-radius: var(--radius);
}

.drag-ghost .prayer-card__star { display: none; }

/* Body class while dragging - disable scroll & text selection */
body.is-dragging {
  touch-action: none;
  user-select: none;
  cursor: grabbing;
}

/* Empty favorites placeholder zone visual */
#grid-favorites:empty { display: none; }
.dashboard.is-editing #grid-favorites:empty {
  display: grid;
  min-height: 80px;
  border: 2px dashed var(--color-divider);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.4);
}

/* ===== Prayer view ===== */
.prayer-view {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 24px 20px 32px;
  animation: fade-in 0.2s ease;
  /* allow vertical scroll, give horizontal swipes to JS for back-to-dashboard */
  touch-action: pan-y;
}

.prayer-view {
  --prayer-font-scale: 1;
}

.prayer-view__head {
  display: grid;
  /* 1fr | auto | 1fr keeps the title visually centered while the zoom group
     sits flush right; the empty left spacer balances the zoom group so the
     title doesn't drift off the page's optical centre. */
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-divider);
}

.prayer-view__head-spacer { display: block; }

.prayer-view__title {
  grid-column: 2;
  margin: 0;
  font-size: 24px;
  font-weight: 500;
  color: var(--color-primary-dark);
  text-align: center;
  min-width: 0;
}

.prayer-view__zoom {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--hover-overlay);
  border-radius: 999px;
}

.prayer-view__zoom-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
  line-height: 1;
  padding: 7px 11px;
  min-width: 36px;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.prayer-view__zoom-btn:hover { background: var(--press-overlay); color: var(--color-primary-dark); }
.prayer-view__zoom-btn:active { transform: scale(0.94); }
.prayer-view__zoom-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.prayer-view__zoom-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.prayer-view__zoom-btn:disabled:hover {
  background: transparent;
  color: var(--color-text-muted);
}

.prayer-view__content {
  font-size: calc(17px * var(--prayer-font-scale));
  line-height: 1.7;
  color: var(--color-text);
}

/* ===== Language toggle (BG ↔ Church Slavonic) =====
   Segmented pill control sits between the intro and the prayer body. Hidden
   when the current prayer has no CS variant - see HasCS in main.go. */
.prayer-lang {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  margin: 0 0 14px;
  background: var(--hover-overlay);
  border-radius: 999px;
}

.prayer-lang__btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-family: inherit;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.2px;
  line-height: 1;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.prayer-lang__btn:hover { color: var(--color-primary-dark); }
.prayer-lang__btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.prayer-lang__btn.is-active {
  background: var(--color-surface);
  color: var(--color-primary-dark);
  box-shadow: var(--shadow-1);
}

.prayer-view__content p { margin: 0 0 14px; }
.prayer-view__content .stanza { margin: 0 0 16px; }

.prayer-view__content hr,
.prayer-view__content .separator {
  /* Tapered gold line - reads like a manuscript section break and stays
     visible in both light and dark themes (whereas a flat divider colour
     vanishes against the dark surface). */
  border: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--color-accent), transparent);
  opacity: 0.7;
  margin: 22px 15%;
}

.prayer-view__content .amen {
  color: var(--color-primary-dark);
  font-weight: 500;
}

.prayer-view__content .rubric {
  display: inline-block;
  font-style: italic;
  color: var(--color-accent);
  font-size: 0.9em;
  letter-spacing: 0.2px;
}

.hidden { display: none !important; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--color-text-muted);
}

.error {
  text-align: center;
  color: var(--color-error);
  padding: 24px;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 768px) {
  .prayer-view { padding: 32px 40px 40px; }
  .prayer-view__title { font-size: 28px; }
  .prayer-view__content { font-size: calc(18px * var(--prayer-font-scale)); }
}

/* ===== Home-extras row (teach + glossary side-by-side above prayer grid) =====
   Two narrow cards sit shoulder-to-shoulder so they don't push the prayer
   grid below the fold. On very narrow phones the cards shed their
   description + CTA to stay legible; at >= 480px they show full content.
   If only one section is present, :only-child lets it span the row instead
   of leaving a dangling empty column. */
.home-extras {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
  margin: 0 0 12px;
}
.home-extras > :only-child {
  grid-column: 1 / -1;
}
.home-extras > .teach-hero,
.home-extras > .recnik-hero {
  margin: 0;
  min-width: 0; /* let grid items shrink below their content width */
}

@media (min-width: 480px) { .home-extras { gap: 12px; } }
@media (min-width: 768px) { .home-extras { gap: 14px; margin-bottom: 14px; } }

/* Compact cards on narrow phones: hide description + CTA, shrink icon.
   The section label above each card already names the topic; the card
   title carries the rest. */
@media (max-width: 479px) {
  .home-extras .teach-card,
  .home-extras .recnik-card {
    grid-template-columns: 40px 1fr;
    gap: 10px;
    padding: 12px 14px;
  }
  .home-extras .teach-card__icon-wrap,
  .home-extras .recnik-card__icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }
  .home-extras .teach-card__icon,
  .home-extras .recnik-card__icon { font-size: 22px; }
  .home-extras .teach-card__title,
  .home-extras .recnik-card__title { font-size: 14px; }
  .home-extras .teach-card__desc,
  .home-extras .recnik-card__desc,
  .home-extras .teach-card__cta,
  .home-extras .recnik-card__cta { display: none; }
}

/* ===== Teaching hero (homepage banner above the prayer grid) ===== */
.teach-hero {
  margin: 0 0 12px;
}

.section-label--teach { color: var(--color-accent); }

.teach-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  text-decoration: none;
  color: inherit;
  border-left: 4px solid var(--color-accent);
  transition: box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.teach-card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.teach-card:active { background: var(--card-active-bg); }
.teach-card:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.teach-card__icon-wrap {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--icon-wrap-bg);
  color: var(--icon-wrap-fg);
}
.teach-card__icon { font-size: 30px; }

.teach-card__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.teach-card__title {
  font-weight: 500;
  font-size: 16px;
  color: var(--color-primary-dark);
  line-height: 1.3;
}
.teach-card__desc {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.4;
}
.teach-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--color-accent);
  font-weight: 500;
}
.teach-card__cta .material-icons-round { font-size: 16px; }

@media (min-width: 768px) {
  .teach-card { padding: 20px 24px; gap: 18px; }
  .teach-card__title { font-size: 18px; }
  .teach-card__desc { font-size: 14px; }
}

/* ===== Reference card (homepage glossary entry) =====
   Same general shape as .teach-card but a different visual register so it
   does not read as "another article" - reference work vs. catechetical
   reading. Left border uses the warm brown of --color-primary-dark instead
   of the gold accent that brackets teach-cards. */
.recnik-hero {
  margin: 0 0 12px;
}

.section-label--recnik { color: var(--color-primary-dark); }

.recnik-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  text-decoration: none;
  color: inherit;
  border-left: 4px solid var(--color-primary-dark);
  transition: box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.recnik-card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.recnik-card:active { background: var(--card-active-bg); }
.recnik-card:focus-visible {
  outline: 3px solid var(--color-primary-dark);
  outline-offset: 2px;
}

.recnik-card__icon-wrap {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--icon-wrap-bg);
  color: var(--icon-wrap-fg);
}
.recnik-card__icon { font-size: 30px; }

.recnik-card__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recnik-card__title {
  font-weight: 500;
  font-size: 16px;
  color: var(--color-primary-dark);
  line-height: 1.3;
}
.recnik-card__desc {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.4;
}
.recnik-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--color-primary-dark);
  font-weight: 500;
}
.recnik-card__cta .material-icons-round { font-size: 16px; }

@media (min-width: 768px) {
  .recnik-card { padding: 20px 24px; gap: 18px; }
  .recnik-card__title { font-size: 18px; }
  .recnik-card__desc { font-size: 14px; }
}

/* ===== Article view (full-page teaching content) ===== */
.article-view {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 24px 20px 32px;
  animation: fade-in 0.2s ease;
}

.article-view__title {
  margin: 0 0 20px;
  font-size: 24px;
  font-weight: 500;
  color: var(--color-primary-dark);
  text-align: center;
  border-bottom: 1px solid var(--color-divider);
  padding-bottom: 14px;
  line-height: 1.3;
}

.article-view__content {
  font-size: 17px;
  line-height: 1.75;
  color: var(--color-text);
}

.article-view__content p { margin: 0 0 14px; }
.article-view__content h2 {
  margin: 28px 0 12px;
  font-size: 20px;
  font-weight: 500;
  color: var(--color-primary-dark);
}
.article-view__content h3 {
  margin: 22px 0 10px;
  font-size: 17px;
  font-weight: 500;
  color: var(--color-primary-dark);
}
.article-view__content ul {
  margin: 0 0 14px;
  padding-left: 22px;
}
.article-view__content li {
  margin: 0 0 8px;
}
.article-view__content blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--color-accent);
  background: var(--card-active-bg);
  border-radius: 0 8px 8px 0;
  color: var(--color-text);
  font-style: italic;
}
.article-view__content blockquote p { margin: 0; }
.article-view__content strong {
  color: var(--color-primary-dark);
  font-weight: 500;
}
/* Inline italic - used for transliterations, foreign-language forms,
   and short stress on technical terms. Muted color so the eye lands on
   the surrounding bold labels first. */
.article-view__content em {
  font-style: italic;
  color: var(--color-text-muted);
}

@media (min-width: 768px) {
  .article-view { padding: 32px 40px 40px; }
  .article-view__title { font-size: 28px; }
  .article-view__content { font-size: 18px; }
  .article-view__content h2 { font-size: 22px; }
  .article-view__content h3 { font-size: 18px; }
}

/* ===== Prayer intro (collapsible context above the prayer text) =====
   Closed by default so readers who came for the text alone see it
   immediately. Tap reveals the "За тази молитва" context with origin,
   meaning and how-to-use guidance. */
.prayer-intro {
  margin: 0 0 20px;
  background: var(--card-active-bg);
  border-radius: 12px;
  overflow: hidden;
}

.prayer-intro__title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  font-weight: 500;
  font-size: 14px;
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.prayer-intro__title::-webkit-details-marker { display: none; }
.prayer-intro__title::marker { content: ''; }
.prayer-intro__title:hover { background: var(--hover-overlay); }
.prayer-intro__title:active { background: var(--press-overlay); }

.prayer-intro__icon {
  font-size: 20px;
  color: var(--color-accent);
}

.prayer-intro__label {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.prayer-intro__chevron {
  font-size: 22px;
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
}
.prayer-intro[open] .prayer-intro__chevron { transform: rotate(180deg); }

.prayer-intro__content {
  padding: 4px 16px 16px;
  font-size: calc(15px * var(--prayer-font-scale));
  line-height: 1.65;
  color: var(--color-text);
  border-top: 1px solid var(--color-divider);
}
.prayer-intro__content p { margin: 12px 0; }
.prayer-intro__content p:first-child { margin-top: 12px; }
.prayer-intro__content p:last-child { margin-bottom: 0; }
.prayer-intro__content strong { color: var(--color-primary-dark); }
.prayer-intro__content blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--color-accent);
  background: var(--color-surface);
  border-radius: 6px;
  color: var(--color-text-muted);
  font-style: italic;
}
.prayer-intro__content blockquote p { margin: 0; }

@media (min-width: 768px) {
  .prayer-intro__content { font-size: calc(16px * var(--prayer-font-scale)); padding: 6px 20px 20px; }
}

/* ===== Related-article link beneath a prayer ===== */
.prayer-related {
  margin: 28px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--color-divider);
}

.prayer-related__link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--card-active-bg);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, transform 0.15s ease;
}
.prayer-related__link:hover { transform: translateY(-1px); }
.prayer-related__link:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.prayer-related__icon {
  font-size: 24px;
  color: var(--color-accent);
}
.prayer-related__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.prayer-related__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
}
.prayer-related__title {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-primary-dark);
  line-height: 1.3;
}
.prayer-related__chev {
  font-size: 20px;
  color: var(--color-text-muted);
}

/* ===== Footer guide (collapsible, fixed at viewport bottom) ===== */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  margin: 0;
  padding: 0;
  /* Let the page underneath catch clicks where the footer is transparent */
  pointer-events: none;
}

.footer__guide {
  pointer-events: auto;
  background: var(--color-surface);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 18px rgba(0,0,0,0.10), 0 -2px 6px rgba(0,0,0,0.06);
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.footer__title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 500;
  font-size: 15px;
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  flex-shrink: 0;
}

/* When the panel is closed the title bar is the only visible part -
   account for the iOS home indicator so the chevron doesn't sit on it. */
.footer__guide:not([open]) .footer__title {
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}
.footer__title::-webkit-details-marker { display: none; }
.footer__title::marker { content: ''; }

.footer__title:hover { background: rgba(0,0,0,0.03); }
.footer__title:active { background: rgba(0,0,0,0.06); }

.footer__title-icon {
  /* Use the accent (gold) so the icon stays readable on both light and dark
     surfaces - `--color-primary` is too close to `--color-surface` in dark
     mode and disappears. Also visually pairs with the gold theme toggle. */
  color: var(--color-accent);
  font-size: 22px;
}

.footer__title-text { flex: 1; }

.footer__chevron {
  font-size: 22px;
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
}

.footer__guide[open] .footer__chevron { transform: rotate(180deg); }

/* Theme toggle sits inside <summary>. Click on it must NOT toggle the
   <details> - JS calls e.stopPropagation(). Visually it's a small icon
   button so it doesn't dominate the title bar. */
.footer__theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-right: 4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-accent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.15s ease;
  flex: 0 0 auto;
}

.footer__theme-toggle:hover { background: var(--hover-overlay); }
.footer__theme-toggle:active { transform: scale(0.92); }
.footer__theme-toggle .material-icons-round { font-size: 20px; }

.footer__content {
  padding: 4px 18px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-divider);
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-text);
  animation: fade-in 0.18s ease;
  /* When the panel is open and content exceeds the 90vh max-height,
     scroll inside the panel instead of clipping. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}

.footer__intro {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  margin: 16px 0 8px;
}

.footer__intro-icon {
  font-size: 22px;
  color: var(--color-accent);
  flex: 0 0 auto;
}

.footer__heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.footer__heading .material-icons-round {
  font-size: 20px;
  flex: 0 0 auto;
}

.footer__heading--ok { color: var(--color-ok); }
.footer__heading--no { color: var(--color-error); }

.footer__content ul {
  margin: 4px 0 4px;
  padding-left: 20px;
}
.footer__content li {
  margin-bottom: 8px;
}

.footer__content strong { color: var(--color-primary-dark); }

.footer__note {
  margin: 18px 0 0;
  padding: 12px 14px;
  background: rgba(201, 162, 91, 0.10);
  border-left: 3px solid var(--color-accent);
  border-radius: 8px;
  font-size: 13px;
  color: var(--color-text);
}

@media (min-width: 768px) {
  .footer__title { padding: 16px 20px; font-size: 16px; }
  .footer__content { padding: 4px 22px calc(24px + env(safe-area-inset-bottom)); font-size: 15px; }
}
