body {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  background: var(--color-bg-canvas);
  color: var(--color-text-primary);
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--color-bg-page);
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: calc(var(--header-height) + var(--inset-safe-top)) minmax(0, 1fr) calc(var(--nav-height) + var(--inset-safe-bottom));
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg-page);
}

.top-nav {
  z-index: 20;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  height: calc(var(--header-height) + var(--inset-safe-top));
  padding: var(--inset-safe-top) var(--page-gutter) var(--space-2);
  background: var(--color-nav-page);
  border-bottom: 1px solid var(--color-border-subtle);
  backdrop-filter: blur(18px);
}

.top-nav-title {
  min-width: max-content;
  padding-block: 2px;
  overflow: visible;
  color: var(--color-brand-emphasis);
  font-size: var(--font-size-screen-title);
  font-weight: var(--font-weight-heavy);
  line-height: var(--line-height-screen-title);
  white-space: nowrap;
  animation: top-nav-title-in var(--motion-control) cubic-bezier(0.2, 0.78, 0.2, 1) both;
}

.top-nav-back {
  display: grid;
  width: max-content;
  max-width: 100%;
  min-height: 38px;
  padding: 0 8px 0 0;
  grid-template-columns: 20px max-content;
  align-items: center;
  justify-content: start;
  gap: 2px;
  background: transparent;
  color: var(--color-brand-emphasis);
  font-size: var(--font-size-screen-title);
  font-weight: var(--font-weight-heavy);
  line-height: var(--line-height-screen-title);
  white-space: nowrap;
  cursor: pointer;
  animation: top-nav-back-in var(--motion-control) cubic-bezier(0.2, 0.78, 0.2, 1) both;
}

.top-nav-back svg {
  width: 22px;
  height: 22px;
}

.top-nav-back span {
  display: block;
  white-space: nowrap;
}

.top-nav-back:active {
  transform: scale(0.97);
}

@keyframes top-nav-title-in {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes top-nav-back-in {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

.top-nav-leading {
  display: flex;
  min-width: 118px;
  flex: 1;
  align-items: center;
  overflow: visible;
}

.top-nav--profile {
  align-items: flex-start;
  border-bottom-color: transparent;
}

.top-nav--profile .top-nav-leading {
  overflow: visible;
}

.top-nav--profile .top-nav-actions {
  min-width: 44px;
  padding-top: 1px;
}

.top-nav-actions {
  display: flex;
  min-width: 94px;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex: 0 0 auto;
}

.screen-stack {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.app-screen {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 0;
  background: var(--color-bg-page);
}

.app-screen.is-active {
  z-index: 2;
  display: block;
  animation: screen-in var(--motion-control) ease-out both;
}

.app-screen.is-screen-leaving {
  z-index: 1;
  display: block;
  pointer-events: none;
  animation: screen-out var(--motion-fast) ease-in both;
}

.scroll-screen.is-active {
  display: block;
}

@keyframes screen-in {
  from { opacity: 0.78; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes screen-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-3px); }
}

.screen-scroll {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.screen-scroll::-webkit-scrollbar {
  display: none;
}

button {
  transform-origin: center;
  transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease,
    border-color var(--motion-fast) ease, opacity var(--motion-fast) ease,
    transform var(--motion-fast) ease;
}

button:active {
  transform: scale(0.97);
}

.icon-button {
  display: grid;
  width: var(--control-min-size);
  height: var(--control-min-size);
  padding: 0;
  place-items: center;
  border-radius: var(--radius-circle);
  background: transparent;
  cursor: pointer;
  transition: background-color var(--motion-instant) ease, transform var(--motion-instant) ease;
}

.icon-button:active {
  transform: scale(0.94);
}

.icon-button--ghost:active {
  background: var(--color-surface-hover);
}

.icon-button--brand {
  width: var(--dimension-control);
  height: var(--dimension-control);
  margin-left: 2px;
  background: var(--color-action-primary);
  color: var(--color-action-primary-text);
  box-shadow: var(--elevation-action);
}

.icon-button--brand svg {
  width: 18px;
  height: 18px;
}

.surface-card {
  background: var(--component-card-bg);
  border: 1px solid var(--component-card-border);
  border-radius: var(--component-card-radius);
  box-shadow: var(--component-card-shadow);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--component-button-primary-height);
  padding: 0 var(--space-5);
  border-radius: var(--component-button-primary-radius);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  transition: transform var(--motion-instant) ease, background-color var(--motion-instant) ease;
}

.primary-button {
  background: var(--component-button-primary-bg);
  color: var(--component-button-primary-fg);
  box-shadow: var(--component-button-primary-shadow);
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(1px) scale(0.992);
}

.secondary-button {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
}

.bottom-nav {
  z-index: 18;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  height: calc(var(--component-nav-height) + var(--inset-safe-bottom));
  padding: var(--space-1) var(--space-2) var(--inset-safe-bottom);
  background: var(--color-nav-surface);
  border-top: 1px solid var(--color-border-subtle);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  min-width: 0;
  min-height: 58px;
  padding: 4px 0 2px;
  place-content: center;
  place-items: center;
  gap: 3px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.85;
}

.nav-item span {
  max-width: 100%;
  overflow: hidden;
  font-size: var(--font-size-micro);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-micro);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item.is-active {
  color: var(--component-nav-active);
}
