:root {
  --sf-shell-nav-height: 72px;
  --sf-shell-safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Phase 1 density: aligned with sf-layout.css breakpoints */
  --sf-shell-bottom-pad: calc(var(--sf-shell-nav-height) + var(--sf-shell-safe-bottom) + 24px);
}

body.sf-student-shell-ready {
  animation: sfShellPageIn .22s ease-out both;
}

body.sf-student-shell-ready::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--sf-shell-nav-height) + var(--sf-shell-safe-bottom) + 18px);
  pointer-events: none;
  z-index: 39;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--bg, #f6f4ef) 86%, transparent));
}

.sf-app-nav {
  position: fixed;
  left: 50%;
  bottom: max(10px, var(--sf-shell-safe-bottom));
  z-index: 50;
  width: min(440px, calc(100vw - 24px));
  min-height: var(--sf-shell-nav-height);
  display: grid;
  grid-template-columns: repeat(var(--sf-nav-count, 4), minmax(0, 1fr));
  gap: 4px;
  padding: 7px;
  border: 1px solid color-mix(in srgb, var(--line, #ddd8cd) 78%, transparent);
  border-radius: 24px;
  background: color-mix(in srgb, var(--panel, #fffdf8) 82%, transparent);
  box-shadow: 0 20px 54px rgba(15, 23, 42, .14);
  backdrop-filter: blur(18px) saturate(1.18);
  transform: translateX(-50%);
}

html[data-sf-theme="dark"] .sf-app-nav {
  background: color-mix(in srgb, var(--panel, #111b2d) 84%, transparent);
  box-shadow: 0 22px 56px rgba(0, 0, 0, .36);
}

.sf-app-nav__item {
  position: relative;
  min-width: 0;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 18px;
  color: var(--muted, #667386);
  text-decoration: none;
  font: inherit;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  transition: background-color .18s ease, color .18s ease, transform .18s ease;
  -webkit-tap-highlight-color: transparent;
}

.sf-app-nav__item:hover,
.sf-app-nav__item:focus-visible {
  color: var(--text, #101827);
  background: color-mix(in srgb, var(--accent-soft, #ddf7f1) 56%, transparent);
  outline: none;
}

.sf-app-nav__item:active {
  transform: translateY(1px) scale(.98);
}

.sf-app-nav__item.is-active {
  color: var(--accent, #0f766e);
  background: color-mix(in srgb, var(--accent-soft, #ddf7f1) 86%, transparent);
}

.sf-app-nav__icon {
  width: 22px;
  height: 22px;
  display: block;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.sf-app-nav__label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.sf-student-shell-ready:not(.chat-page) {
  padding-bottom: var(--sf-shell-bottom-pad) !important;
}

.chat-page.sf-student-shell-ready .chat-shell {
  padding-bottom: calc(var(--sf-shell-nav-height) + var(--sf-shell-safe-bottom) + 12px);
}

.chat-page.sf-student-shell-ready::after {
  display: none;
}

.chat-page.sf-student-shell-ready .chat-composer {
  bottom: calc(var(--sf-shell-nav-height) + var(--sf-shell-safe-bottom) + 6px);
  border-bottom: 1px solid var(--chat-phone-line, rgba(15, 23, 42, .09));
}

@media (min-width: 900px) {
  :root {
    --sf-shell-nav-height: 58px;
  }

  body.sf-student-shell-ready::after {
    height: 82px;
    opacity: .68;
  }

  .sf-app-nav {
    width: auto;
    min-width: 372px;
    min-height: var(--sf-shell-nav-height);
    grid-template-columns: repeat(var(--sf-nav-count, 4), 74px);
    padding: 6px;
    border-radius: 999px;
    opacity: .82;
  }

  .sf-app-nav:hover,
  .sf-app-nav:focus-within {
    opacity: 1;
  }

  .sf-app-nav__item {
    min-height: 46px;
    border-radius: 999px;
    font-size: 9px;
  }

  .sf-app-nav__icon {
    width: 19px;
    height: 19px;
  }

  .chat-page.sf-student-shell-ready .chat-shell {
    padding-bottom: calc(var(--sf-shell-nav-height) + 24px);
  }

  .chat-page.sf-student-shell-ready .chat-composer {
    bottom: calc(var(--sf-shell-nav-height) + 12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.sf-student-shell-ready {
    animation: none;
  }

  .sf-app-nav__item {
    transition: none;
  }
}

@keyframes sfShellPageIn {
  from {
    opacity: .96;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
