/* ============================================================
   APP SHELL
   The frame everything else sits inside: header, view stage,
   bottom nav. Feature CSS never touches these.
   ============================================================ */

.app {
  position: relative;
  z-index: var(--z-app);
  width: 100%;
  max-width: var(--app-w);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────── */
.hdr {
  position: sticky;
  top: 0;
  z-index: var(--z-hdr);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 14px var(--s-5);
  border-bottom: var(--border-w) solid var(--rim);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
}

.hdr-brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}
.hdr-mark {
  font-size: 1.25rem;
  line-height: 1;
}
.hdr-word {
  font-size: calc(1.35rem * var(--display-scale));
  color: var(--text);
  white-space: nowrap;
}

.hdr-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}
.hdr-slot {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}
.hdr-fixed {
  display: flex;
  align-items: center;
}
.hdr-name {
  font-size: 0.8rem;
  font-weight: var(--body-weight-strong);
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 9ch;
}

/* ── View stage ───────────────────────────────────────────── */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view.is-active .page {
  animation: pageIn var(--dur-slow) var(--ease) both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-5) calc(var(--nav-h) + 56px);
}

/* ── Bottom nav ───────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-w);
  z-index: var(--z-nav);
  display: flex;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border-top: var(--border-w) solid var(--rim);
  padding: var(--s-2) 0 calc(var(--s-2) + env(safe-area-inset-bottom, 0px));
}

.nav-item {
  flex: 1;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 0;
  position: relative;
  color: var(--text-dimmer);
  transition: color var(--dur-fast) ease;
}
.nav-item svg {
  width: 20px;
  height: 20px;
}
.nav-item span {
  font-size: 0.6rem;
  font-weight: var(--body-weight-strong);
  letter-spacing: 0.05em;
}
.nav-item:hover {
  color: var(--text);
}
.nav-item.is-active {
  color: var(--accent-2);
}
.nav-item.is-active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-2);
}
.nav-item:focus-visible {
  outline-offset: -2px;
}

/* ── Wider than a phone: centre the frame and edge it ──────── */
@media (min-width: 520px) {
  body {
    background: color-mix(in srgb, var(--bg) 70%, #000);
  }
  .app {
    margin: 0 auto;
    box-shadow: 0 0 0 1px var(--rim), 0 32px 80px rgba(0, 0, 0, 0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  .view.is-active .page { animation: none; }
}
