@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: url("../fonts/baloo2-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/nunito-latin.woff2") format("woff2");
}

/* Elements toggled via the `hidden` attribute (install banner, offline
   banner) must actually disappear — without this, an author rule like
   `.install-banner { display: flex }` below outranks the browser's own
   `[hidden] { display: none }` default, and the attribute has no visible
   effect even though it's set correctly in the DOM. */
[hidden] {
  display: none !important;
}

:root {
  --cream: #EAF7F4;
  --cream-deep: #D9EFEA;
  --accent: #2F86EB;
  --accent-dark: #1B5FA6;
  --gold: #1EA672;
  --text: #1F3347;
  --text-soft: #5A7386;
  --white: #FFFFFF;
  --radius: 20px;
  --radius-round: 999px;
  --shadow: 0 6px 18px rgba(31, 58, 95, 0.14);
  --header-h: 68px;
  --tabbar-h: 84px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--text);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, .brand-name {
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 700;
  margin: 0;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ─────────────── Header ─────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  padding: env(safe-area-inset-top) 20px 0;
  background: var(--cream);
  border-bottom: 3px solid var(--cream-deep);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 36px; height: 36px; border-radius: 10px; }
.brand-name { font-size: 19px; color: var(--accent-dark); }

/* ─────────────── Main / layout ─────────────── */

.main {
  min-height: calc(100vh - var(--header-h) - var(--tabbar-h));
  padding: 24px 20px calc(var(--tabbar-h) + 24px);
  max-width: 720px;
  margin: 0 auto;
}

.page-title {
  font-size: 32px;
  color: var(--accent-dark);
  margin-bottom: 18px;
  letter-spacing: -0.5px;
}

.back-link {
  display: inline-block;
  margin-bottom: 12px;
  font-weight: 700;
  color: var(--text-soft);
  font-size: 16px;
}

.empty-state {
  font-size: 18px;
  color: var(--text-soft);
  text-align: center;
  padding: 40px 20px;
}

/* ─────────────── Bottom tab bar ─────────────── */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tabbar-h);
  display: flex;
  background: var(--white);
  border-top: 3px solid var(--cream-deep);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.tab-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}

.tab-bar-icon { font-size: 26px; line-height: 1; }

.tab-bar-item.is-active { color: var(--accent-dark); }

/* ─────────────── Buttons ─────────────── */

.btn {
  border: none;
  border-radius: var(--radius-round);
  padding: 16px 28px;
  font-size: 18px;
  font-weight: 800;
  background: var(--white);
  color: var(--accent-dark);
  box-shadow: var(--shadow);
  min-height: 56px;
}

.btn:disabled { opacity: 0.4; cursor: default; }

.btn-primary { background: var(--accent); color: var(--white); }
.btn-round { min-width: 56px; }

.btn-huge {
  display: block;
  width: 100%;
  font-size: 24px;
  padding: 22px 28px;
  margin: 18px 0;
}

/* ─────────────── Hero (Home) ─────────────── */

.hero { text-align: center; padding-top: 12px; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 800;
  color: var(--gold);
  font-size: 14px;
  margin: 0 0 6px;
}

.hero-title {
  font-size: 30px;
  color: var(--accent-dark);
  margin-bottom: 22px;
}

/* ─────────────── Card lists (Daily Readings, book clip list) ─────────────── */

.card-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  width: 100%;
  border: 3px solid transparent;
  text-align: left;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  font-weight: 700;
}

.card-row-date { color: var(--text-soft); font-size: 14px; font-weight: 600; white-space: nowrap; }

.card-row.is-active { border-color: var(--accent); }

/* ─────────────── Books index ─────────────── */

.book-section { margin-bottom: 28px; }

.section-title {
  font-size: 22px;
  color: var(--accent-dark);
  margin-bottom: 12px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.book-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 84px;
  justify-content: center;
}

.book-card-name { font-size: 17px; font-weight: 800; }
.book-card-progress { font-size: 14px; color: var(--text-soft); font-weight: 700; }

/* ─────────────── Book detail ─────────────── */

.progress-indicator {
  font-weight: 800;
  color: var(--text-soft);
  margin: 0 0 8px;
}

.resume-banner {
  background: var(--cream-deep);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.resume-actions { display: flex; gap: 10px; }
.resume-actions .btn { flex: 1; padding: 14px; font-size: 16px; min-height: 48px; }

/* ─────────────── Player ─────────────── */

.player-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  aspect-ratio: 9 / 16;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #000;
}

.player-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.player-tap-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

.player-tap-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-tap-icon {
  font-size: 48px;
  color: var(--white);
  opacity: 0;
  transform: scale(0.8);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.player-tap-overlay.is-flashing .player-tap-icon {
  animation: player-tap-flash 0.6s ease-out;
}

@keyframes player-tap-flash {
  0% { opacity: 0.9; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.15); }
}

.mock-player {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  color: var(--white);
  text-align: center;
  padding: 20px;
}

.mock-player-emoji { font-size: 48px; }
.mock-player-title { font-size: 20px; font-weight: 800; }
.mock-player-hint { font-size: 13px; opacity: 0.9; max-width: 320px; }
.mock-player .btn { margin-top: 8px; }

.player-controls {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.player-controls .btn { flex: 1; }

.up-next {
  margin-top: 14px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.up-next-label {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1.5px;
  font-weight: 800;
  color: var(--gold);
}

.up-next-title { font-weight: 700; font-size: 16px; }

/* ─────────────── Status / install banners ─────────────── */

.status-banner {
  position: sticky;
  top: calc(var(--header-h) + env(safe-area-inset-top));
  z-index: 9;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
}

.status-banner-offline {
  background: #F5A623;
  color: #3D2B00;
}

.install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.install-banner-icon { font-size: 28px; flex-shrink: 0; }

.install-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-soft);
}

.install-banner-text strong { font-size: 15px; color: var(--text); }

.install-banner .btn {
  padding: 10px 18px;
  font-size: 15px;
  min-height: 44px;
  flex-shrink: 0;
}

.install-banner-dismiss {
  border: none;
  background: none;
  font-size: 18px;
  color: var(--text-soft);
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
}

.install-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(74, 50, 34, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.install-dialog {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.install-dialog-steps {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 15px;
  line-height: 1.4;
}

.empty-state .btn { margin-top: 16px; }

/* ─────────────── Admin ("Add a Day") form ─────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field:last-child { margin-bottom: 0; }

.field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}

.field input,
.field select {
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--cream-deep);
  background: var(--white);
  color: var(--text);
  min-height: 48px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.admin-output {
  width: 100%;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 14px;
  border-radius: var(--radius);
  border: 2px solid var(--cream-deep);
  background: var(--white);
  color: var(--text);
  resize: vertical;
  margin-bottom: 12px;
}

/* ─────────────── Small screens get slightly tighter spacing ─────────────── */

@media (max-width: 380px) {
  .hero-title, .page-title { font-size: 26px; }
  .btn-huge { font-size: 20px; }
}
