:root {
  --app-chrome-fixed-left: 16px;
  --app-chrome-fixed-width: calc(100vw - 32px);
  --app-chrome-fixed-top: 18px;
  --app-chrome-fixed-bottom: 12px;
  --app-chrome-topbar-height: 0px;
  --app-chrome-bottom-nav-height: 0px;
  --app-chrome-content-top-offset: 18px;
  --app-chrome-content-bottom-offset: 100px;
  --app-chrome-page-gap: 0px;
}

.app-shell {
  padding-top: var(--app-chrome-content-top-offset);
  padding-bottom: var(--app-chrome-content-bottom-offset);
}

body.native-app .app-shell,
body.compact-layout .app-shell,
body.home-sabbath-module-active .app-shell,
body.home-topic-request-active .app-shell {
  padding-top: var(--app-chrome-content-top-offset);
  padding-bottom: var(--app-chrome-content-bottom-offset);
}

@media (max-width: 900px) {
  body:not(.native-app):not(.compact-layout) .app-shell {
    padding-top: var(--app-chrome-content-top-offset);
    padding-bottom: var(--app-chrome-content-bottom-offset);
  }
}

.topbar {
  position: fixed !important;
  top: var(--app-chrome-fixed-top) !important;
  left: var(--app-chrome-fixed-left) !important;
  width: var(--app-chrome-fixed-width) !important;
  z-index: 140;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 14px 16px 16px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow:
    0 18px 34px rgba(13, 30, 58, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(18px) saturate(1.06);
}

.topbar-brand {
  min-width: 0;
}

.topbar .eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 1.9rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.02;
}

.topbar-session {
  min-width: max-content;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  position: relative;
  flex-wrap: nowrap;
}

.font-scale-menu {
  position: relative;
  flex: 0 0 auto;
}

.font-scale-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 999px;
  border: 1px solid rgba(47, 128, 237, 0.22);
  background: rgba(255, 255, 255, 0.84);
}

.font-scale-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  white-space: nowrap;
  box-shadow: 0 14px 28px rgba(17, 32, 61, 0.14);
}

.font-scale-menu-toggle {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 12px;
}

.font-scale-btn {
  min-width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid rgba(47, 128, 237, 0.22);
  background: rgba(245, 250, 255, 0.9);
  color: #2b5ca5;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 670;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.font-scale-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.font-scale-value {
  min-width: 42px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 640;
  color: #2b5ca5;
}

.settings-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(47, 128, 237, 0.26);
  background: rgba(255, 255, 255, 0.88);
  color: #2f67b7;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.settings-btn.has-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  padding: 0;
  overflow: hidden;
}

.settings-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page {
  display: none;
  position: relative;
  z-index: 1;
  padding-top: var(--app-chrome-page-gap);
  overflow-x: hidden;
}

.page.is-active {
  display: block;
}

body.sabbath-school-reader-page-active:not(.native-app):not(.compact-layout) .app-shell {
  height: calc(100dvh - 28px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.bottom-nav {
  position: fixed;
  left: var(--app-chrome-fixed-left);
  width: var(--app-chrome-fixed-width);
  right: auto;
  bottom: var(--app-chrome-fixed-bottom);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 24px rgba(18, 31, 58, 0.16);
  backdrop-filter: blur(18px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 7px 6px;
  z-index: 140;
}

.nav-item {
  --tone: var(--home-tone);
  --tone-soft: var(--home-soft);
  position: relative;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font: inherit;
  color: var(--tone);
  opacity: 0.56;
  display: grid;
  gap: 3px;
  justify-items: center;
  padding: 5px 4px;
  font-size: 0.64rem;
  letter-spacing: 0.01em;
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease;
}

.nav-badge {
  position: absolute;
  top: 2px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ff3b30;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 590;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(255, 59, 48, 0.4);
}

.nav-item[data-nav="home"] {
  --tone: var(--home-tone);
  --tone-soft: var(--home-soft);
}

.nav-item[data-nav="mission"] {
  --tone: var(--mission-tone);
  --tone-soft: var(--mission-soft);
}

.nav-item[data-nav="service"] {
  --tone: var(--service-tone);
  --tone-soft: var(--service-soft);
}

.nav-item[data-nav="evangelism"] {
  --tone: var(--evangelism-tone);
  --tone-soft: var(--evangelism-soft);
}

.nav-item.is-active {
  opacity: 1;
  background: var(--tone-soft);
}

.nav-item:active {
  transform: translateY(1px);
}

body.native-app .topbar,
body.compact-layout .topbar {
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  padding:
    calc(12px + var(--screen-top-blocker))
    calc(12px + var(--safe-right))
    14px
    calc(12px + var(--safe-left));
}

body.native-app .topbar h1,
body.compact-layout .topbar h1 {
  font-size: 2.02rem;
  line-height: 1.05;
}

body.native-app .topbar .eyebrow,
body.compact-layout .topbar .eyebrow {
  font-size: 0.76rem;
}

body.native-app .font-scale-btn,
body.native-app .font-scale-menu-toggle,
body.compact-layout .font-scale-btn,
body.compact-layout .font-scale-menu-toggle {
  min-width: 32px;
  height: 32px;
}

body.native-app .nav-item,
body.compact-layout .nav-item {
  font-size: 0.68rem;
  gap: 3px;
}

body.native-app .bottom-nav,
body.compact-layout .bottom-nav {
  left: 0 !important;
  width: 100vw !important;
  right: auto;
  bottom: 0 !important;
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  border-bottom: 0 !important;
  padding: 6px 8px calc(4px + var(--safe-bottom));
}

@media (max-width: 900px) {
  body:not(.native-app):not(.compact-layout) .topbar {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    padding:
      calc(12px + var(--screen-top-blocker))
      calc(12px + var(--safe-right))
      14px
      calc(12px + var(--safe-left));
  }

  body:not(.native-app):not(.compact-layout) .topbar h1 {
    font-size: 2.02rem;
    line-height: 1.05;
  }

  body:not(.native-app):not(.compact-layout) .topbar .eyebrow {
    font-size: 0.76rem;
  }

  body:not(.native-app):not(.compact-layout) .font-scale-btn {
    min-width: 32px;
    height: 32px;
  }

  body:not(.native-app):not(.compact-layout) .font-scale-menu-toggle {
    min-width: 32px;
    height: 32px;
  }

  body:not(.native-app):not(.compact-layout) .bottom-nav {
    left: 0 !important;
    width: 100vw !important;
    right: auto;
    bottom: 0 !important;
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    padding: 6px 8px calc(4px + var(--safe-bottom));
  }

  body:not(.native-app):not(.compact-layout) .nav-item {
    font-size: 0.68rem;
    gap: 3px;
    padding: 5px 4px;
  }
}
